AVFilmGrainAFGS1Params, the offending struct, is using sizeof(AVFilmGrainParams)
when it should not. This change also forgot to make the necessary changes to the
frame threading sync code.

Both of these will be fixed by the following commit.

Signed-off-by: James Almer <jamr...@gmail.com>
---
 libavcodec/h2645_sei.c    | 17 +++++------------
 libavcodec/h2645_sei.h    |  2 +-
 libavcodec/hevc/hevcdec.c |  4 ++--
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 33551f5406..a481dbca2c 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -245,12 +245,7 @@ static int decode_registered_user_data(H2645SEI *h, 
GetByteContext *gb,
 
         provider_oriented_code = bytestream2_get_byteu(gb);
         if (provider_oriented_code == aom_grain_provider_oriented_code) {
-            if (!h->aom_film_grain) {
-                h->aom_film_grain = av_mallocz(sizeof(*h->aom_film_grain));
-                if (!h->aom_film_grain)
-                    return AVERROR(ENOMEM);
-            }
-            return ff_aom_parse_film_grain_sets(h->aom_film_grain,
+            return ff_aom_parse_film_grain_sets(&h->aom_film_grain,
                                                 gb->buffer,
                                                 
bytestream2_get_bytes_left(gb));
         }
@@ -894,11 +889,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
     }
 
 #if CONFIG_HEVC_SEI
-    if (sei->aom_film_grain) {
-        ret = ff_aom_attach_film_grain_sets(sei->aom_film_grain, frame);
-        if (ret < 0)
-            return ret;
-    }
+    ret = ff_aom_attach_film_grain_sets(&sei->aom_film_grain, frame);
+    if (ret < 0)
+        return ret;
 #endif
 
     return 0;
@@ -925,7 +918,7 @@ void ff_h2645_sei_reset(H2645SEI *s)
     s->ambient_viewing_environment.present = 0;
     s->mastering_display.present = 0;
     s->content_light.present = 0;
+    s->aom_film_grain.enable = 0;
 
     av_freep(&s->film_grain_characteristics);
-    av_freep(&s->aom_film_grain);
 }
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 8bcdc2bc5f..f001427e16 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -138,10 +138,10 @@ typedef struct H2645SEI {
     H2645SEIAmbientViewingEnvironment ambient_viewing_environment;
     H2645SEIMasteringDisplay mastering_display;
     H2645SEIContentLight content_light;
+    AVFilmGrainAFGS1Params aom_film_grain;
 
     // Dynamic allocations due to large size.
     H2645SEIFilmGrainCharacteristics* film_grain_characteristics;
-    AVFilmGrainAFGS1Params* aom_film_grain;
 } H2645SEI;
 
 enum {
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 1ea8df0fa0..900895598f 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -413,7 +413,7 @@ static int export_stream_params_from_sei(HEVCContext *s)
     }
 
     if ((s->sei.common.film_grain_characteristics && 
s->sei.common.film_grain_characteristics->present) ||
-        (s->sei.common.aom_film_grain && s->sei.common.aom_film_grain->enable))
+        s->sei.common.aom_film_grain.enable)
         avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
 
     return 0;
@@ -3268,7 +3268,7 @@ static int hevc_frame_start(HEVCContext *s, 
HEVCLayerContext *l,
         s->cur_frame->f->flags &= ~AV_FRAME_FLAG_KEY;
 
     s->cur_frame->needs_fg = ((s->sei.common.film_grain_characteristics && 
s->sei.common.film_grain_characteristics->present) ||
-                              (s->sei.common.aom_film_grain && 
s->sei.common.aom_film_grain->enable)) &&
+                              s->sei.common.aom_film_grain.enable) &&
         !(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) &&
         !s->avctx->hwaccel;
 
-- 
2.47.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-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to