From 0f4bf97027499b483dfdd5b27e40be6f7f1d3c0c Mon Sep 17 00:00:00 2001
From: Javier Cabezas <jcabgz@gmail.com>
Date: Thu, 19 Jan 2012 02:06:29 +0100
Subject: [PATCH] DNxHD: frame multithreading
Signed-off-by: Javier Cabezas <jcabgz@gmail.com>
---
libavcodec/dnxhddec.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 2548614..0f1ce9e 100644
|
a
|
b
|
|
| 30 | 30 | #include "get_bits.h" |
| 31 | 31 | #include "dnxhddata.h" |
| 32 | 32 | #include "dsputil.h" |
| | 33 | #include "thread.h" |
| 33 | 34 | |
| 34 | 35 | typedef struct DNXHDContext { |
| 35 | 36 | AVCodecContext *avctx; |
| … |
… |
static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
| 365 | 366 | DNXHDContext *ctx = avctx->priv_data; |
| 366 | 367 | AVFrame *picture = data; |
| 367 | 368 | int first_field = 1; |
| | 369 | int ret; |
| 368 | 370 | |
| 369 | 371 | av_dlog(avctx, "frame size %d\n", buf_size); |
| 370 | 372 | |
| … |
… |
static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
| 385 | 387 | |
| 386 | 388 | if (first_field) { |
| 387 | 389 | if (ctx->picture.data[0]) |
| 388 | | avctx->release_buffer(avctx, &ctx->picture); |
| 389 | | if (avctx->get_buffer(avctx, &ctx->picture) < 0) { |
| | 390 | ff_thread_release_buffer(avctx, &ctx->picture); |
| | 391 | if ((ret = ff_thread_get_buffer(avctx, &ctx->picture)) < 0) { |
| 390 | 392 | av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
| 391 | | return -1; |
| | 393 | return ret; |
| 392 | 394 | } |
| 393 | 395 | } |
| 394 | 396 | |
| | 397 | ff_thread_finish_setup(avctx); |
| | 398 | |
| 395 | 399 | dnxhd_decode_macroblocks(ctx, buf + 0x280, buf_size - 0x280); |
| 396 | 400 | |
| 397 | 401 | if (first_field && ctx->picture.interlaced_frame) { |
| … |
… |
static av_cold int dnxhd_decode_close(AVCodecContext *avctx)
|
| 411 | 415 | DNXHDContext *ctx = avctx->priv_data; |
| 412 | 416 | |
| 413 | 417 | if (ctx->picture.data[0]) |
| 414 | | avctx->release_buffer(avctx, &ctx->picture); |
| | 418 | ff_thread_release_buffer(avctx, &ctx->picture); |
| 415 | 419 | free_vlc(&ctx->ac_vlc); |
| 416 | 420 | free_vlc(&ctx->dc_vlc); |
| 417 | 421 | free_vlc(&ctx->run_vlc); |
| … |
… |
AVCodec ff_dnxhd_decoder = {
|
| 426 | 430 | .init = dnxhd_decode_init, |
| 427 | 431 | .close = dnxhd_decode_close, |
| 428 | 432 | .decode = dnxhd_decode_frame, |
| 429 | | .capabilities = CODEC_CAP_DR1, |
| | 433 | .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, |
| 430 | 434 | .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), |
| 431 | 435 | }; |