From: Aman Gupta <a...@tmm1.net> CC data is fed to in small chunks (usually 60 bytes at a time) and is parsed fully by the eia608 decoder. There is no reason to copy it into a secondary buffer first. --- libavcodec/ccaption_dec.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c index 9f67caa..4b1d376 100644 --- a/libavcodec/ccaption_dec.c +++ b/libavcodec/ccaption_dec.c @@ -167,8 +167,6 @@ typedef struct CCaptionSubContext { int64_t startv_time; int64_t end_time; char prev_cmd[2]; - /* buffer to store pkt data */ - AVBufferRef *pktbuf; }CCaptionSubContext; @@ -185,11 +183,6 @@ static av_cold int init_decoder(AVCodecContext *avctx) if(ret < 0) { return ret; } - /* allocate pkt buffer */ - ctx->pktbuf = av_buffer_alloc(128); - if( !ctx->pktbuf) { - ret = AVERROR(ENOMEM); - } return ret; } @@ -197,7 +190,6 @@ static av_cold int close_decoder(AVCodecContext *avctx) { CCaptionSubContext *ctx = avctx->priv_data; av_bprint_finalize( &ctx->buffer, NULL); - av_buffer_unref(&ctx->pktbuf); return 0; } @@ -524,23 +516,11 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp { CCaptionSubContext *ctx = avctx->priv_data; AVSubtitle *sub = data; - uint8_t *bptr = NULL; + uint8_t *bptr = avpkt->data; int len = avpkt->size; int ret = 0; int i; - if ( ctx->pktbuf->size < len) { - ret = av_buffer_realloc(&ctx->pktbuf, len); - if(ret < 0) { - av_log(ctx, AV_LOG_WARNING, "Insufficient Memory of %d truncated to %d\n",len, ctx->pktbuf->size); - len = ctx->pktbuf->size; - ret = 0; - } - } - memcpy(ctx->pktbuf->data, avpkt->data, len); - bptr = ctx->pktbuf->data; - - for (i = 0; i < len; i += 3) { uint8_t cc_type = *(bptr + i) & 3; if (validate_cc_data_pair( bptr + i) ) -- 2.5.3 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel