[FFmpeg-devel] lavc/videotoolboxdec: fix crop handling when multithreaded

Submitted by Rodger Combs on Sept. 7, 2019, 3:31 a.m.

Details

Message ID 20190907033106.35816-1-rodger.combs@gmail.com
State Accepted
Commit 77937a42e7127271bd50d7f8035c3ebd5a1047c5
Headers show

Commit Message

Rodger Combs Sept. 7, 2019, 3:31 a.m.
This was partially fixed by 233cd89, but it made changes to AVFrame fields
from within end_frame, which doesn't work consistently when multithreading
is enabled. This is what the post_process function is for.
---
 libavcodec/videotoolbox.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Aman Gupta Sept. 7, 2019, 4:40 a.m.
On Fri, Sep 6, 2019 at 8:37 PM Rodger Combs <rodger.combs@gmail.com> wrote:

> This was partially fixed by 233cd89, but it made changes to AVFrame fields
> from within end_frame, which doesn't work consistently when multithreading
> is enabled. This is what the post_process function is for.


Looks good to me.


> ---
>  libavcodec/videotoolbox.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
> index c718e82cc5..7948d21bcc 100644
> --- a/libavcodec/videotoolbox.c
> +++ b/libavcodec/videotoolbox.c
> @@ -91,6 +91,11 @@ static int videotoolbox_postproc_frame(void *avctx,
> AVFrame *frame)
>          return AVERROR_EXTERNAL;
>      }
>
> +    frame->crop_right = 0;
> +    frame->crop_left = 0;
> +    frame->crop_top = 0;
> +    frame->crop_bottom = 0;
> +
>      frame->data[3] = (uint8_t*)ref->pixbuf;
>
>      if (ref->hw_frames_ctx) {
> @@ -898,11 +903,6 @@ static int
> videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame)
>      AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx);
>      VTContext *vtctx = avctx->internal->hwaccel_priv_data;
>
> -    frame->crop_right = 0;
> -    frame->crop_left = 0;
> -    frame->crop_top = 0;
> -    frame->crop_bottom = 0;
> -
>      if (vtctx->reconfig_needed == true) {
>          vtctx->reconfig_needed = false;
>          av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox decoder needs
> reconfig, restarting..\n");
> --
> 2.21.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Patch hide | download patch | download mbox

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index c718e82cc5..7948d21bcc 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -91,6 +91,11 @@  static int videotoolbox_postproc_frame(void *avctx, AVFrame *frame)
         return AVERROR_EXTERNAL;
     }
 
+    frame->crop_right = 0;
+    frame->crop_left = 0;
+    frame->crop_top = 0;
+    frame->crop_bottom = 0;
+
     frame->data[3] = (uint8_t*)ref->pixbuf;
 
     if (ref->hw_frames_ctx) {
@@ -898,11 +903,6 @@  static int videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame)
     AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx);
     VTContext *vtctx = avctx->internal->hwaccel_priv_data;
 
-    frame->crop_right = 0;
-    frame->crop_left = 0;
-    frame->crop_top = 0;
-    frame->crop_bottom = 0;
-
     if (vtctx->reconfig_needed == true) {
         vtctx->reconfig_needed = false;
         av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox decoder needs reconfig, restarting..\n");