diff mbox series

[FFmpeg-devel,2/2] pthread_frame: change the criterium for updating thread contexts

Message ID 20200609112019.21270-2-anton@khirnov.net
State Accepted
Commit f1feb3bd9dbff6e15ee9f981d79d353ffdc15c0b
Headers show
Series [FFmpeg-devel,1/2] codec_desc: drop the INTRA_ONLY property from TAK | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Anton Khirnov June 9, 2020, 11:20 a.m. UTC
Currently the next thread's context is updated from the previous one's
if the codec descriptor is not marked as intra-only. That is not
entirely correct, since that property does not necessarily imply
anything about how a specific decoder implementation behaves.

Instead, use the presence of the update_thread_context() callback to
decide whether an update should be performed. Fixes races in CFHD,
should cause no behaviour change in any other decoders.
---
 libavcodec/pthread_frame.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Almer June 10, 2020, 10:09 p.m. UTC | #1
On 6/9/2020 8:20 AM, Anton Khirnov wrote:
> Currently the next thread's context is updated from the previous one's
> if the codec descriptor is not marked as intra-only. That is not
> entirely correct, since that property does not necessarily imply
> anything about how a specific decoder implementation behaves.
> 
> Instead, use the presence of the update_thread_context() callback to
> decide whether an update should be performed. Fixes races in CFHD,
> should cause no behaviour change in any other decoders.
> ---
>  libavcodec/pthread_frame.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
> index 601f170447..3255aa9337 100644
> --- a/libavcodec/pthread_frame.c
> +++ b/libavcodec/pthread_frame.c
> @@ -246,7 +246,7 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
>  {
>      int err = 0;
>  
> -    if (dst != src && (for_user || !(src->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY))) {
> +    if (dst != src && (for_user || src->codec->update_thread_context)) {
>          dst->time_base = src->time_base;
>          dst->framerate = src->framerate;
>          dst->width     = src->width;

LGTM.
diff mbox series

Patch

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 601f170447..3255aa9337 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -246,7 +246,7 @@  static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
 {
     int err = 0;
 
-    if (dst != src && (for_user || !(src->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY))) {
+    if (dst != src && (for_user || src->codec->update_thread_context)) {
         dst->time_base = src->time_base;
         dst->framerate = src->framerate;
         dst->width     = src->width;