From 24456882f378c3154645b2b833b6f5af6e6f3ef7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20=C3=96man?= Date: Wed, 20 Jun 2007 08:53:53 +0000 Subject: [PATCH] =?utf8?q?Do=20not=20reuse=20the=20rbsp=20de-escape=20buff?= =?utf8?q?er=20if=20both=20the=20intra=20and=20inter=20-nal=20units=20are?= =?utf8?q?=20escaped=20patch=20by=20Andreas=20=C3=96man:=20\andreas=20oleb?= =?utf8?q?yn=20nu/=20original=20thread:=20[FFmpeg-devel]=20[PATCH]=20h264:?= =?utf8?q?=20rbsp=20de-escape=20and=20data=20partitioning..=20date:=2006/2?= =?utf8?q?0/2007=2009:32=20AM?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Originally committed as revision 9374 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/h264.c | 9 ++++++--- libavcodec/h264.h | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index a8801a1..99e104e 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1392,6 +1392,7 @@ static inline void write_back_motion(H264Context *h, int mb_type){ static uint8_t *decode_nal(H264Context *h, uint8_t *src, int *dst_length, int *consumed, int length){ int i, si, di; uint8_t *dst; + int bufidx; // src[0]&0x80; //forbidden bit h->nal_ref_idc= src[0]>>5; @@ -1420,8 +1421,9 @@ static uint8_t *decode_nal(H264Context *h, uint8_t *src, int *dst_length, int *c return src; } - h->rbsp_buffer= av_fast_realloc(h->rbsp_buffer, &h->rbsp_buffer_size, length); - dst= h->rbsp_buffer; + bufidx = h->nal_unit_type == NAL_DPC ? 1 : 0; // use second escape buffer for inter data + h->rbsp_buffer[bufidx]= av_fast_realloc(h->rbsp_buffer[bufidx], &h->rbsp_buffer_size[bufidx], length); + dst= h->rbsp_buffer[bufidx]; if (dst == NULL){ return NULL; @@ -8237,7 +8239,8 @@ static int decode_end(AVCodecContext *avctx) H264Context *h = avctx->priv_data; MpegEncContext *s = &h->s; - av_freep(&h->rbsp_buffer); + av_freep(&h->rbsp_buffer[0]); + av_freep(&h->rbsp_buffer[1]); free_tables(h); //FIXME cleanup init stuff perhaps MPV_common_end(s); diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 913f4fd..1669e8e 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -160,8 +160,8 @@ typedef struct H264Context{ MpegEncContext s; int nal_ref_idc; int nal_unit_type; - uint8_t *rbsp_buffer; - unsigned int rbsp_buffer_size; + uint8_t *rbsp_buffer[2]; + unsigned int rbsp_buffer_size[2]; /** * Used to parse AVC variant of h264 -- 2.7.4