DNxHD: frame multithreading

Signed-off-by: Javier Cabezas <jcabgz@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Javier Cabezas 2012-01-19 02:06:29 +01:00 committed by Michael Niedermayer
parent 1ce8377c78
commit 1406d9ddc6

View File

@ -30,6 +30,7 @@
#include "get_bits.h"
#include "dnxhddata.h"
#include "dsputil.h"
#include "thread.h"
typedef struct DNXHDContext {
AVCodecContext *avctx;
@ -365,6 +366,7 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
DNXHDContext *ctx = avctx->priv_data;
AVFrame *picture = data;
int first_field = 1;
int ret;
av_dlog(avctx, "frame size %d\n", buf_size);
@ -385,13 +387,15 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if (first_field) {
if (ctx->picture.data[0])
avctx->release_buffer(avctx, &ctx->picture);
if (avctx->get_buffer(avctx, &ctx->picture) < 0) {
ff_thread_release_buffer(avctx, &ctx->picture);
if ((ret = ff_thread_get_buffer(avctx, &ctx->picture)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
return ret;
}
}
ff_thread_finish_setup(avctx);
dnxhd_decode_macroblocks(ctx, buf + 0x280, buf_size - 0x280);
if (first_field && ctx->picture.interlaced_frame) {
@ -411,7 +415,7 @@ static av_cold int dnxhd_decode_close(AVCodecContext *avctx)
DNXHDContext *ctx = avctx->priv_data;
if (ctx->picture.data[0])
avctx->release_buffer(avctx, &ctx->picture);
ff_thread_release_buffer(avctx, &ctx->picture);
free_vlc(&ctx->ac_vlc);
free_vlc(&ctx->dc_vlc);
free_vlc(&ctx->run_vlc);
@ -426,6 +430,6 @@ AVCodec ff_dnxhd_decoder = {
.init = dnxhd_decode_init,
.close = dnxhd_decode_close,
.decode = dnxhd_decode_frame,
.capabilities = CODEC_CAP_DR1,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
.long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"),
};