[FFmpeg-devel] [PATCH] libavcodec/ccaption_dec: remove unnecessary buffering of closed caption packets
Clément Bœsch
u at pkh.me
Sun Jan 3 13:07:15 CET 2016
On Fri, Jan 01, 2016 at 04:40:06PM -0800, Aman Gupta wrote:
> From: Aman Gupta <aman at 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) )
This indeed LGTM, but I'm not the maintainer.
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160103/a62fb6da/attachment.sig>
More information about the ffmpeg-devel
mailing list