comparison h264.c @ 5174:2e038003cdfb libavcodec

Do not reuse the rbsp de-escape buffer if both the intra and inter -nal units are escaped patch by Andreas ªÓman: \andreas olebyn nu/ original thread: [FFmpeg-devel] [PATCH] h264: rbsp de-escape and data partitioning.. date: 06/20/2007 09:32 AM
author benoit
date Wed, 20 Jun 2007 08:53:53 +0000
parents 60a4f209838b
children ea61020e5e87
comparison
equal deleted inserted replaced
5173:3c321b5d5c61 5174:2e038003cdfb
1390 * @returns decoded bytes, might be src+1 if no escapes 1390 * @returns decoded bytes, might be src+1 if no escapes
1391 */ 1391 */
1392 static uint8_t *decode_nal(H264Context *h, uint8_t *src, int *dst_length, int *consumed, int length){ 1392 static uint8_t *decode_nal(H264Context *h, uint8_t *src, int *dst_length, int *consumed, int length){
1393 int i, si, di; 1393 int i, si, di;
1394 uint8_t *dst; 1394 uint8_t *dst;
1395 int bufidx;
1395 1396
1396 // src[0]&0x80; //forbidden bit 1397 // src[0]&0x80; //forbidden bit
1397 h->nal_ref_idc= src[0]>>5; 1398 h->nal_ref_idc= src[0]>>5;
1398 h->nal_unit_type= src[0]&0x1F; 1399 h->nal_unit_type= src[0]&0x1F;
1399 1400
1418 *dst_length= length; 1419 *dst_length= length;
1419 *consumed= length+1; //+1 for the header 1420 *consumed= length+1; //+1 for the header
1420 return src; 1421 return src;
1421 } 1422 }
1422 1423
1423 h->rbsp_buffer= av_fast_realloc(h->rbsp_buffer, &h->rbsp_buffer_size, length); 1424 bufidx = h->nal_unit_type == NAL_DPC ? 1 : 0; // use second escape buffer for inter data
1424 dst= h->rbsp_buffer; 1425 h->rbsp_buffer[bufidx]= av_fast_realloc(h->rbsp_buffer[bufidx], &h->rbsp_buffer_size[bufidx], length);
1426 dst= h->rbsp_buffer[bufidx];
1425 1427
1426 if (dst == NULL){ 1428 if (dst == NULL){
1427 return NULL; 1429 return NULL;
1428 } 1430 }
1429 1431
8235 static int decode_end(AVCodecContext *avctx) 8237 static int decode_end(AVCodecContext *avctx)
8236 { 8238 {
8237 H264Context *h = avctx->priv_data; 8239 H264Context *h = avctx->priv_data;
8238 MpegEncContext *s = &h->s; 8240 MpegEncContext *s = &h->s;
8239 8241
8240 av_freep(&h->rbsp_buffer); 8242 av_freep(&h->rbsp_buffer[0]);
8243 av_freep(&h->rbsp_buffer[1]);
8241 free_tables(h); //FIXME cleanup init stuff perhaps 8244 free_tables(h); //FIXME cleanup init stuff perhaps
8242 MPV_common_end(s); 8245 MPV_common_end(s);
8243 8246
8244 // memset(h, 0, sizeof(H264Context)); 8247 // memset(h, 0, sizeof(H264Context));
8245 8248