[FFmpeg-trac] #5543(avcodec:new): av_packet_ref incorrectly processes packets with offset between data and buffer

FFmpeg trac at avcodec.org
Thu May 12 11:55:23 CEST 2016


#5543: av_packet_ref incorrectly processes packets with offset between data and
buffer
---------------------------------+--------------------------------------
             Reporter:  mrlika   |                     Type:  defect
               Status:  new      |                 Priority:  critical
            Component:  avcodec  |                  Version:  git-master
             Keywords:           |               Blocked By:
             Blocking:           |  Reproduced by developer:  0
Analyzed by developer:  0        |
---------------------------------+--------------------------------------
 As example aac_adtstoasc bitstream filter returns pakcets with pkt->data
 != pkt->buf->data (i.e. with offset) when I started to use new av_bsf_*
 API.

 Then if you call av_packet_ref on such packet you will get incorrect dst
 packet because it just sets dst->data = dst->buf->data in the code:


 {{{
 int av_packet_ref(AVPacket *dst, const AVPacket *src)
 {
     int ret;

     ret = av_packet_copy_props(dst, src);
     if (ret < 0)
         return ret;

     if (!src->buf) {
         ret = packet_alloc(&dst->buf, src->size);
         if (ret < 0)
             goto fail;
         memcpy(dst->buf->data, src->data, src->size);
     } else {
         dst->buf = av_buffer_ref(src->buf);
         if (!dst->buf) {
             ret = AVERROR(ENOMEM);
             goto fail;
         }
     }

     dst->size = src->size;
     dst->data = dst->buf->data;
     return 0;
 fail:
     av_packet_free_side_data(dst);
     return ret;
 }
 }}}


 For example FLV muxer calls av_packet_ref internally that causes errors
 when processing packets from aac_adtstoasc bitstream filter.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/5543>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list