Ticket #13186: 012_mpeg2fix_avcodec_encode_video2.patch

File 012_mpeg2fix_avcodec_encode_video2.patch, 1.5 KB (added by Peter Bennett, 3 years ago)

Patch 012 - Fix deprecated avcodec_encode_video2 in mpeg2fix.cpp

  • mythtv/programs/mythtranscode/mpeg2fix.cpp

    diff --git a/mythtv/programs/mythtranscode/mpeg2fix.cpp b/mythtv/programs/mythtranscode/mpeg2fix.cpp
    index 8248da8..9726eee 100644
    a b bool MPEG2fixup::BuildFrame(AVPacket *pkt, QString fname) 
    12931293    int got_packet = 0;
    12941294    int ret;
    12951295
    1296     // Need to call this repeatedly as it seems to be pipelined.  The first
    1297     // call will return no packet, then the second one will flush it.  In case
    1298     // it becomes more pipelined, just loop until it creates a packet or errors
    1299     // out.
    1300     while (got_packet <= 0)
    1301     {
    1302         ret = avcodec_encode_video2(c, pkt, picture, &got_packet);
     1296    ret = avcodec_send_frame(c, picture);
    13031297
     1298    bool flushed = false;
     1299    while (ret >= 0)
     1300    {
     1301        // ret = avcodec_encode_video2(c, pkt, picture, &got_packet);
     1302        ret = avcodec_receive_packet(c, pkt);
     1303        if (ret == 0)
     1304            got_packet = 1;
     1305        if (ret == AVERROR(EAGAIN))
     1306            ret = 0;
    13041307        if (ret < 0)
    1305         {
    1306             LOG(VB_GENERAL, LOG_ERR,
    1307                 QString("avcodec_encode_video2 failed (%1)").arg(ret));
    1308             return true;
    1309         }
     1308            break;
     1309        if (flushed)
     1310            break;
     1311        // flush
     1312        ret = avcodec_send_frame(c, NULL);
     1313        flushed = true;
     1314    }
     1315
     1316    if (ret < 0 || !got_packet)
     1317    {
     1318        LOG(VB_GENERAL, LOG_ERR,
     1319            QString("avcodec_encode_video2 failed (%1)").arg(ret));
     1320        return true;
    13101321    }
    13111322
    13121323    if (!fname.isEmpty())