diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-11-21 21:34:46 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-03-08 07:38:30 +0100 |
commit | 759001c534287a96dc96d1e274665feb7059145d (patch) | |
tree | 6ace9560c20aa30db92067c5b45d7bd86e458d10 /libavcodec/lcldec.c | |
parent | 6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff) | |
download | ffmpeg-759001c534287a96dc96d1e274665feb7059145d.tar.gz |
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/lcldec.c')
-rw-r--r-- | libavcodec/lcldec.c | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index 914d4b2775..957143dd75 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -55,8 +55,6 @@ * Decoder context */ typedef struct LclDecContext { - AVFrame pic; - // Image type int imgtype; // Compression type @@ -160,6 +158,7 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i */ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { + AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; LclDecContext * const c = avctx->priv_data; @@ -176,17 +175,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac unsigned int mthread_inlen, mthread_outlen; unsigned int len = buf_size; - if(c->pic.data[0]) - avctx->release_buffer(avctx, &c->pic); - - c->pic.reference = 0; - c->pic.buffer_hints = FF_BUFFER_HINTS_VALID; - if ((ret = ff_get_buffer(avctx, &c->pic)) < 0) { + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - outptr = c->pic.data[0]; // Output image pointer + outptr = frame->data[0]; // Output image pointer /* Decompress frame */ switch (avctx->codec_id) { @@ -374,9 +368,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac } /* Convert colorspace */ - y_out = c->pic.data[0] + (height - 1) * c->pic.linesize[0]; - u_out = c->pic.data[1] + (height - 1) * c->pic.linesize[1]; - v_out = c->pic.data[2] + (height - 1) * c->pic.linesize[2]; + y_out = frame->data[0] + (height - 1) * frame->linesize[0]; + u_out = frame->data[1] + (height - 1) * frame->linesize[1]; + v_out = frame->data[2] + (height - 1) * frame->linesize[2]; switch (c->imgtype) { case IMGTYPE_YUV111: for (row = 0; row < height; row++) { @@ -385,9 +379,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac u_out[col] = *encoded++ + 128; v_out[col] = *encoded++ + 128; } - y_out -= c->pic.linesize[0]; - u_out -= c->pic.linesize[1]; - v_out -= c->pic.linesize[2]; + y_out -= frame->linesize[0]; + u_out -= frame->linesize[1]; + v_out -= frame->linesize[2]; } break; case IMGTYPE_YUV422: @@ -400,14 +394,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac v_out[ col >> 1 ] = *encoded++ + 128; v_out[(col >> 1) + 1] = *encoded++ + 128; } - y_out -= c->pic.linesize[0]; - u_out -= c->pic.linesize[1]; - v_out -= c->pic.linesize[2]; + y_out -= frame->linesize[0]; + u_out -= frame->linesize[1]; + v_out -= frame->linesize[2]; } break; case IMGTYPE_RGB24: for (row = height - 1; row >= 0; row--) { - pixel_ptr = row * c->pic.linesize[0]; + pixel_ptr = row * frame->linesize[0]; memcpy(outptr + pixel_ptr, encoded, 3 * width); encoded += 3 * width; } @@ -420,9 +414,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac u_out[col >> 2] = *encoded++ + 128; v_out[col >> 2] = *encoded++ + 128; } - y_out -= c->pic.linesize[0]; - u_out -= c->pic.linesize[1]; - v_out -= c->pic.linesize[2]; + y_out -= frame->linesize[0]; + u_out -= frame->linesize[1]; + v_out -= frame->linesize[2]; } break; case IMGTYPE_YUV211: @@ -433,26 +427,26 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac u_out[col >> 1] = *encoded++ + 128; v_out[col >> 1] = *encoded++ + 128; } - y_out -= c->pic.linesize[0]; - u_out -= c->pic.linesize[1]; - v_out -= c->pic.linesize[2]; + y_out -= frame->linesize[0]; + u_out -= frame->linesize[1]; + v_out -= frame->linesize[2]; } break; case IMGTYPE_YUV420: - u_out = c->pic.data[1] + ((height >> 1) - 1) * c->pic.linesize[1]; - v_out = c->pic.data[2] + ((height >> 1) - 1) * c->pic.linesize[2]; + u_out = frame->data[1] + ((height >> 1) - 1) * frame->linesize[1]; + v_out = frame->data[2] + ((height >> 1) - 1) * frame->linesize[2]; for (row = 0; row < height - 1; row += 2) { for (col = 0; col < width - 1; col += 2) { memcpy(y_out + col, encoded, 2); encoded += 2; - memcpy(y_out + col - c->pic.linesize[0], encoded, 2); + memcpy(y_out + col - frame->linesize[0], encoded, 2); encoded += 2; u_out[col >> 1] = *encoded++ + 128; v_out[col >> 1] = *encoded++ + 128; } - y_out -= c->pic.linesize[0] << 1; - u_out -= c->pic.linesize[1]; - v_out -= c->pic.linesize[2]; + y_out -= frame->linesize[0] << 1; + u_out -= frame->linesize[1]; + v_out -= frame->linesize[2]; } break; default: @@ -461,7 +455,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac } *got_frame = 1; - *(AVFrame*)data = c->pic; /* always report that the buffer was completely consumed */ return buf_size; @@ -625,8 +618,6 @@ static av_cold int decode_end(AVCodecContext *avctx) LclDecContext * const c = avctx->priv_data; av_freep(&c->decomp_buf); - if (c->pic.data[0]) - avctx->release_buffer(avctx, &c->pic); #if CONFIG_ZLIB_DECODER if (avctx->codec_id == AV_CODEC_ID_ZLIB) inflateEnd(&c->zstream); |