Ticket #13186: 001_avcodec_decode_audio4.2.patch

File 001_avcodec_decode_audio4.2.patch, 3.1 KB (added by Peter Bennett, 3 years ago)

Patch 001 avcode_decode_audio4 (updated)

  • mythtv/libs/libmyth/audio/audiooutput.cpp

    diff --git a/mythtv/libs/libmyth/audio/audiooutput.cpp b/mythtv/libs/libmyth/audio/audiooutput.cpp
    index 2dfba52..7c00970 100644
    a b int AudioOutput::DecodeAudio(AVCodecContext *ctx, 
    621621                             uint8_t *buffer, int &data_size,
    622622                             const AVPacket *pkt)
    623623{
    624     int got_frame = 0;
     624    bool got_frame = false;
    625625    int ret;
    626626    char error[AV_ERROR_MAX_STRING_SIZE];
    627627
    int AudioOutput::DecodeAudio(AVCodecContext *ctx, 
    638638        av_frame_unref(_frame);
    639639    }
    640640
    641     ret = avcodec_decode_audio4(ctx, _frame, &got_frame, pkt);
    642     if (ret < 0)
     641//  SUGGESTION
     642//  Now that avcodec_decode_audio4 is deprecated and replaced
     643//  by 2 calls (receive frame and send packet), this could be optimized
     644//  into separate routines or separate threads.
     645//  Also now that it always consumes a whole buffer some code
     646//  in the caller may be able to be optimized.
     647    ret = avcodec_receive_frame(ctx,_frame);
     648    if (ret == 0)
     649        got_frame = true;
     650    if (ret == AVERROR(EAGAIN))
     651        ret = 0;
     652    if (ret == 0)
     653        ret = avcodec_send_packet(ctx, pkt);
     654    if (ret == AVERROR(EAGAIN))
     655        ret = 0;
     656    else if (ret < 0)
    643657    {
    644658        LOG(VB_AUDIO, LOG_ERR, LOC +
    645659            QString("audio decode error: %1 (%2)")
    int AudioOutput::DecodeAudio(AVCodecContext *ctx, 
    647661            .arg(got_frame));
    648662        return ret;
    649663    }
     664    else
     665        ret = pkt->size;
    650666
    651667    if (!got_frame)
    652668    {
  • mythtv/libs/libmyth/audio/audiooutpututil.cpp

    diff --git a/mythtv/libs/libmyth/audio/audiooutpututil.cpp b/mythtv/libs/libmyth/audio/audiooutpututil.cpp
    index 03e310d..ea517a6 100644
    a b int AudioOutputUtil::DecodeAudio(AVCodecContext *ctx, 
    245245                                 const AVPacket *pkt)
    246246{
    247247    MythAVFrame frame;
    248     int got_frame = 0;
     248    bool got_frame = false;
    249249    int ret;
    250250    char error[AV_ERROR_MAX_STRING_SIZE];
    251251
    int AudioOutputUtil::DecodeAudio(AVCodecContext *ctx, 
    255255        return AVERROR(ENOMEM);
    256256    }
    257257
    258     ret = avcodec_decode_audio4(ctx, frame, &got_frame, pkt);
    259     if (ret < 0)
     258//  SUGGESTION
     259//  Now that avcodec_decode_audio4 is deprecated and replaced
     260//  by 2 calls (receive frame and send packet), this could be optimized
     261//  into separate routines or separate threads.
     262//  Also now that it always consumes a whole buffer some code
     263//  in the caller may be able to be optimized.
     264    ret = avcodec_receive_frame(ctx,frame);
     265    if (ret == 0)
     266        got_frame = true;
     267    if (ret == AVERROR(EAGAIN))
     268        ret = 0;
     269    if (ret == 0)
     270        ret = avcodec_send_packet(ctx, pkt);
     271    if (ret == AVERROR(EAGAIN))
     272        ret = 0;
     273    else if (ret < 0)
    260274    {
    261275        LOG(VB_AUDIO, LOG_ERR, LOC +
    262276            QString("audio decode error: %1 (%2)")
    int AudioOutputUtil::DecodeAudio(AVCodecContext *ctx, 
    264278            .arg(got_frame));
    265279        return ret;
    266280    }
     281    else
     282        ret = pkt->size;
    267283
    268284    if (!got_frame)
    269285    {