[FFmpeg-devel] avcodec/h264_slice: set the SEI parameters early on the AVCodecContext

Message ID 20190529131614.9476-1-robux4@ycbcr.xyz
State Accepted
Commit 8788dd67b851ec652bdd83bb5d5afb12101b7c6f
Headers

Commit Message

Steve Lhomme May 29, 2019, 1:16 p.m. UTC
It's better to do it before the buffers are actually created. At least in VLC
we currently don't support changing some parameters dynamically easily so we
don't use the information if it comes after the buffer are created.

Co-authored-by: James Almer <jamrial@gmail.com>
---
 libavcodec/h264_slice.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Comments

James Almer May 29, 2019, 1:56 p.m. UTC | #1
On 5/29/2019 10:16 AM, Steve Lhomme wrote:
> It's better to do it before the buffers are actually created. At least in VLC
> we currently don't support changing some parameters dynamically easily so we
> don't use the information if it comes after the buffer are created.
> 
> Co-authored-by: James Almer <jamrial@gmail.com>
> ---
>  libavcodec/h264_slice.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> index 1c9a270fb6..5ceee107a0 100644
> --- a/libavcodec/h264_slice.c
> +++ b/libavcodec/h264_slice.c
> @@ -1092,6 +1092,12 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl
>                  h->avctx->colorspace      = sps->colorspace;
>              }
>          }
> +
> +        if (h->sei.alternative_transfer.present &&
> +            av_color_transfer_name(h->sei.alternative_transfer.preferred_transfer_characteristics) &&
> +            h->sei.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) {
> +            h->avctx->color_trc = h->sei.alternative_transfer.preferred_transfer_characteristics;
> +        }
>      }
>  
>      if (!h->context_initialized || must_reinit || needs_reinit) {
> @@ -1332,12 +1338,6 @@ static int h264_export_frame_props(H264Context *h)
>          h->sei.picture_timing.timecode_cnt = 0;
>      }
>  
> -    if (h->sei.alternative_transfer.present &&
> -        av_color_transfer_name(h->sei.alternative_transfer.preferred_transfer_characteristics) &&
> -        h->sei.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) {
> -        h->avctx->color_trc = cur->f->color_trc = h->sei.alternative_transfer.preferred_transfer_characteristics;
> -    }
> -
>      return 0;

LTGM
  

Patch

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 1c9a270fb6..5ceee107a0 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1092,6 +1092,12 @@  static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl
                 h->avctx->colorspace      = sps->colorspace;
             }
         }
+
+        if (h->sei.alternative_transfer.present &&
+            av_color_transfer_name(h->sei.alternative_transfer.preferred_transfer_characteristics) &&
+            h->sei.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) {
+            h->avctx->color_trc = h->sei.alternative_transfer.preferred_transfer_characteristics;
+        }
     }
 
     if (!h->context_initialized || must_reinit || needs_reinit) {
@@ -1332,12 +1338,6 @@  static int h264_export_frame_props(H264Context *h)
         h->sei.picture_timing.timecode_cnt = 0;
     }
 
-    if (h->sei.alternative_transfer.present &&
-        av_color_transfer_name(h->sei.alternative_transfer.preferred_transfer_characteristics) &&
-        h->sei.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) {
-        h->avctx->color_trc = cur->f->color_trc = h->sei.alternative_transfer.preferred_transfer_characteristics;
-    }
-
     return 0;
 }