Browse Source

DNxHD: frame multithreading

Signed-off-by: Javier Cabezas <jcabgz@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
tags/n0.10
Javier Cabezas Michael Niedermayer 13 years ago
parent
commit
1406d9ddc6
1 changed files with 9 additions and 5 deletions
  1. +9
    -5
      libavcodec/dnxhddec.c

+ 9
- 5
libavcodec/dnxhddec.c View File

@@ -30,6 +30,7 @@
#include "get_bits.h" #include "get_bits.h"
#include "dnxhddata.h" #include "dnxhddata.h"
#include "dsputil.h" #include "dsputil.h"
#include "thread.h"


typedef struct DNXHDContext { typedef struct DNXHDContext {
AVCodecContext *avctx; AVCodecContext *avctx;
@@ -365,6 +366,7 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
DNXHDContext *ctx = avctx->priv_data; DNXHDContext *ctx = avctx->priv_data;
AVFrame *picture = data; AVFrame *picture = data;
int first_field = 1; int first_field = 1;
int ret;


av_dlog(avctx, "frame size %d\n", buf_size); 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 (first_field) {
if (ctx->picture.data[0]) 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"); 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); dnxhd_decode_macroblocks(ctx, buf + 0x280, buf_size - 0x280);


if (first_field && ctx->picture.interlaced_frame) { 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; DNXHDContext *ctx = avctx->priv_data;


if (ctx->picture.data[0]) 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->ac_vlc);
free_vlc(&ctx->dc_vlc); free_vlc(&ctx->dc_vlc);
free_vlc(&ctx->run_vlc); free_vlc(&ctx->run_vlc);
@@ -426,6 +430,6 @@ AVCodec ff_dnxhd_decoder = {
.init = dnxhd_decode_init, .init = dnxhd_decode_init,
.close = dnxhd_decode_close, .close = dnxhd_decode_close,
.decode = dnxhd_decode_frame, .decode = dnxhd_decode_frame,
.capabilities = CODEC_CAP_DR1,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
.long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"),
}; };

Loading…
Cancel
Save