# HG changeset patch # User diego # Date 1276102581 0 # Node ID f60cd3b9d453dc447b3187ac1a336ae617949982 # Parent 2dead2f28eac2565100e6d03dcd450229209303e libmpeg2: Move pending_buffer stuff to local decoder context. It is only used in our wrapper code, so there is no point to patch it into our libmpeg2 copy. This also helps when trying to use external libmpeg2. patch by Luca Barbato diff -r 2dead2f28eac -r f60cd3b9d453 libmpcodecs/vd_libmpeg2.c --- a/libmpcodecs/vd_libmpeg2.c Wed Jun 09 16:07:46 2010 +0000 +++ b/libmpcodecs/vd_libmpeg2.c Wed Jun 09 16:56:21 2010 +0000 @@ -52,6 +52,8 @@ int width; int height; double aspect; + unsigned char *pending_buffer; + int pending_length; } vd_libmpeg2_ctx_t; // to set/get/query special features/parameters @@ -115,9 +117,6 @@ context->mpeg2dec = mpeg2dec; sh->context = context; - mpeg2dec->pending_buffer = 0; - mpeg2dec->pending_length = 0; - return 1; } @@ -126,7 +125,7 @@ int i; vd_libmpeg2_ctx_t *context = sh->context; mpeg2dec_t * mpeg2dec = context->mpeg2dec; - if (mpeg2dec->pending_buffer) free(mpeg2dec->pending_buffer); + if (context->pending_buffer) free(context->pending_buffer); mpeg2dec->decoder.convert=NULL; mpeg2dec->decoder.convert_id=NULL; mpeg2_close (mpeg2dec); @@ -170,8 +169,8 @@ ((char*)data+len)[3]=0xff; len+=4; - if (mpeg2dec->pending_length) { - mpeg2_buffer (mpeg2dec, mpeg2dec->pending_buffer, mpeg2dec->pending_buffer + mpeg2dec->pending_length); + if (context->pending_length) { + mpeg2_buffer (mpeg2dec, context->pending_buffer, context->pending_buffer + context->pending_length); } else { mpeg2_buffer (mpeg2dec, data, (uint8_t *)data+len); } @@ -185,9 +184,9 @@ switch(state){ case STATE_BUFFER: - if (mpeg2dec->pending_length) { + if (context->pending_length) { // just finished the pending data, continue with processing of the passed buffer - mpeg2dec->pending_length = 0; + context->pending_length = 0; mpeg2_buffer (mpeg2dec, data, (uint8_t *)data+len); } else { // parsing of the passed buffer finished, return. @@ -288,17 +287,17 @@ // decoding done: if(info->display_fbuf) { mp_image_t* mpi = info->display_fbuf->id; - if (mpeg2dec->pending_length == 0) { - mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start; - mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length); - memcpy(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length); + if (context->pending_length == 0) { + context->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start; + context->pending_buffer = realloc(context->pending_buffer, context->pending_length); + memcpy(context->pending_buffer, mpeg2dec->buf_start, context->pending_length); } else { // still some data in the pending buffer, shouldn't happen - mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start; - memmove(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length); - mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length + len); - memcpy(mpeg2dec->pending_buffer+mpeg2dec->pending_length, data, len); - mpeg2dec->pending_length += len; + context->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start; + memmove(context->pending_buffer, mpeg2dec->buf_start, context->pending_length); + context->pending_buffer = realloc(context->pending_buffer, context->pending_length + len); + memcpy(context->pending_buffer+context->pending_length, data, len); + context->pending_length += len; } return mpi; } diff -r 2dead2f28eac -r f60cd3b9d453 libmpeg2/libmpeg2_changes.diff --- a/libmpeg2/libmpeg2_changes.diff Wed Jun 09 16:07:46 2010 +0000 +++ b/libmpeg2/libmpeg2_changes.diff Wed Jun 09 16:56:21 2010 +0000 @@ -355,16 +355,6 @@ }; typedef struct { -@@ -223,6 +232,9 @@ - //int8_t q_scale_type, scaled[4]; - uint8_t quantizer_matrix[4][64]; - uint8_t new_quantizer_matrix[4][64]; -+ -+ unsigned char *pending_buffer; -+ int pending_length; - }; - - typedef struct { @@ -226,7 +238,7 @@ }; diff -r 2dead2f28eac -r f60cd3b9d453 libmpeg2/mpeg2_internal.h --- a/libmpeg2/mpeg2_internal.h Wed Jun 09 16:07:46 2010 +0000 +++ b/libmpeg2/mpeg2_internal.h Wed Jun 09 16:56:21 2010 +0000 @@ -232,9 +232,6 @@ //int8_t q_scale_type, scaled[4]; uint8_t quantizer_matrix[4][64]; uint8_t new_quantizer_matrix[4][64]; - - unsigned char *pending_buffer; - int pending_length; }; typedef struct {