diff mbox

[FFmpeg-devel] avcodec/dvdec: add frame threads

Message ID 20190417161639.822-1-onemda@gmail.com
State Accepted
Commit 833ae5f4bfdc73f7b3a4852469b6a62979e3d203
Headers show

Commit Message

Paul B Mahol April 17, 2019, 4:16 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/dvdec.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Michael Niedermayer April 17, 2019, 11:19 p.m. UTC | #1
On Wed, Apr 17, 2019 at 06:16:39PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavcodec/dvdec.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)

Is this intended to be 100% same output ?

I have a few cases that produce differences. Dont have a good testcase though
./ffmpeg -i ~/tickets/1589/A1590.dv avi-b.avi
produces different output.
oddly -f framecrc produces the same output
not sure this is a problem or not the input file may have issues

[...]
diff mbox

Patch

diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 7b16787e27..89864f2edc 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -49,6 +49,7 @@ 
 #include "internal.h"
 #include "put_bits.h"
 #include "simple_idct.h"
+#include "thread.h"
 
 typedef struct BlockInfo {
     const uint32_t *factor_table;
@@ -499,7 +500,7 @@  static int dvvideo_decode_frame(AVCodecContext *avctx, void *data,
     uint8_t *buf = avpkt->data;
     int buf_size = avpkt->size;
     DVVideoContext *s = avctx->priv_data;
-    AVFrame *frame = data;
+    ThreadFrame frame = { .f = data };
     const uint8_t *vsc_pack;
     int apt, is16_9, ret;
     const AVDVProfile *sys;
@@ -520,9 +521,9 @@  static int dvvideo_decode_frame(AVCodecContext *avctx, void *data,
         s->sys = sys;
     }
 
-    s->frame            = frame;
-    frame->key_frame    = 1;
-    frame->pict_type    = AV_PICTURE_TYPE_I;
+    s->frame            = frame.f;
+    frame.f->key_frame  = 1;
+    frame.f->pict_type  = AV_PICTURE_TYPE_I;
     avctx->pix_fmt      = s->sys->pix_fmt;
     avctx->framerate    = av_inv_q(s->sys->time_base);
 
@@ -539,14 +540,14 @@  static int dvvideo_decode_frame(AVCodecContext *avctx, void *data,
         ff_set_sar(avctx, s->sys->sar[is16_9]);
     }
 
-    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+    if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
         return ret;
-    frame->interlaced_frame = 1;
-    frame->top_field_first  = 0;
+    frame.f->interlaced_frame = 1;
+    frame.f->top_field_first  = 0;
 
     /* Determine the codec's field order from the packet */
     if ( *vsc_pack == dv_video_control ) {
-        frame->top_field_first = !(vsc_pack[3] & 0x40);
+        frame.f->top_field_first = !(vsc_pack[3] & 0x40);
     }
 
     s->buf = buf;
@@ -569,6 +570,6 @@  AVCodec ff_dvvideo_decoder = {
     .priv_data_size = sizeof(DVVideoContext),
     .init           = dvvideo_decode_init,
     .decode         = dvvideo_decode_frame,
-    .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS,
+    .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS,
     .max_lowres     = 3,
 };