[FFmpeg-trac] #4874(undetermined:new): AAC decoder frame->nb_samples & frame->channels is wrong at get_buffer2

FFmpeg trac at avcodec.org
Wed Sep 23 10:30:13 CEST 2015


#4874: AAC decoder frame->nb_samples & frame->channels is wrong at get_buffer2
-------------------------------------+-------------------------------------
             Reporter:  zylthinking  |                    Owner:
                 Type:  defect       |                   Status:  new
             Priority:  normal       |                Component:
              Version:  git-master   |  undetermined
             Keywords:  aac          |               Resolution:
             Blocking:               |               Blocked By:
Analyzed by developer:  0            |  Reproduced by developer:  0
-------------------------------------+-------------------------------------

Comment (by zylthinking):

 Replying to [comment:3 cehoyos]:

 it just happens to be correct.
 to be precise, I print information in the default audio_get_buffer with
 the code:
 __android_log_print(6, "zylthinking", "frame->linesize[0] = %d, planes =
 %d, frame->nb_extended_buf = %d:%d\n", frame->linesize[0], planes,
 frame->nb_extended_buf, AV_NUM_DATA_POINTERS);

 and I get:
 E/zylthinking(13386): frame->linesize[0] = 8192, planes = 2,
 frame->nb_extended_buf = 0:8
 this is the lc-aac, and you see
 1. channel is 2, not 1
 2.  pool->linesize[0] is 8192, this is the exactly a buffer size large
 enough to avoid the errors; in fact, only 4096 bytes is needed for 1
 channel

 the conclusion is that:
 1. the default get_buffer known what I don't know, e.g. the internal
 FramePool, all information is query from it and it even use a large buffer
 to avoid buffer size issues; though it has enough and correct
 information(maybe, if it still have some other source to query the correct
 nb_samples) to get the buffer size needed


 while, I have to say, for a user provided get_buffer2 hook,  the only
 information for me to use is the information decoder passed to me. So, the
 decoder should not tell me wrong things.

 see the code in utils.c
 {{{
 static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
 {
     FramePool *pool = avctx->internal->pool;
     int planes = pool->planes;
     int i;

     frame->linesize[0] = pool->linesize[0];
     __android_log_print(6, "zylthinking", "frame->linesize[0] = %d, planes
 = %d, frame->nb_extended_buf = %d:%d\n", frame->linesize[0], planes,
 frame->nb_extended_buf, AV_NUM_DATA_POINTERS);

     if (planes > AV_NUM_DATA_POINTERS) {
         frame->extended_data = av_mallocz_array(planes,
 sizeof(*frame->extended_data));
         frame->nb_extended_buf = planes - AV_NUM_DATA_POINTERS;
         frame->extended_buf  = av_mallocz_array(frame->nb_extended_buf,
                                           sizeof(*frame->extended_buf));
         if (!frame->extended_data || !frame->extended_buf) {
             av_freep(&frame->extended_data);
             av_freep(&frame->extended_buf);
             return AVERROR(ENOMEM);
         }
     } else {
         frame->extended_data = frame->data;
         av_assert0(frame->nb_extended_buf == 0);
     }

     for (i = 0; i < FFMIN(planes, AV_NUM_DATA_POINTERS); i++) {
         frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
         if (!frame->buf[i])
             goto fail;
         frame->extended_data[i] = frame->data[i] = frame->buf[i]->data;
     }
     for (i = 0; i < frame->nb_extended_buf; i++) {
         frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]);
         if (!frame->extended_buf[i])
             goto fail;
         frame->extended_data[i + AV_NUM_DATA_POINTERS] =
 frame->extended_buf[i]->data;
     }

     if (avctx->debug & FF_DEBUG_BUFFERS)
         av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame
 %p", frame);

     return 0;
 fail:
     av_frame_unref(frame);
     return AVERROR(ENOMEM);
 }
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/4874#comment:7>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list