diff mbox series

[FFmpeg-devel,22/29] avcodec/dpx: respect side data preference

Message ID 20240304130657.30631-22-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/29] lavu/opt: factor per-type dispatch out of av_opt_get() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov March 4, 2024, 1:06 p.m. UTC
From: Niklas Haas <git@haasn.dev>

If the time code side data is overridden by the packet level, we also
make sure not to update `p->metadata` to a mismatched timecode.
---
 libavcodec/dpx.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index 31e4a3f82c..80616d98a2 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -287,19 +287,21 @@  static int decode_frame(AVCodecContext *avctx, AVFrame *p,
         tc = av_bswap32(read32(&buf, endian));
 
         if (i != 0xFFFFFFFF) {
-            AVFrameSideData *tcside =
-                av_frame_new_side_data(p, AV_FRAME_DATA_S12M_TIMECODE,
-                                       sizeof(uint32_t) * 4);
-            if (!tcside)
-                return AVERROR(ENOMEM);
+            AVFrameSideData *tcside;
+            ret = ff_frame_new_side_data(avctx, p, AV_FRAME_DATA_S12M_TIMECODE,
+                                         sizeof(uint32_t) * 4, &tcside);
+            if (ret < 0)
+                return ret;
 
-            tc_sd = (uint32_t*)tcside->data;
-            tc_sd[0] = 1;
-            tc_sd[1] = tc;
+            if (tcside) {
+                tc_sd = (uint32_t*)tcside->data;
+                tc_sd[0] = 1;
+                tc_sd[1] = tc;
 
-            av_timecode_make_smpte_tc_string2(tcbuf, avctx->framerate,
-                                              tc_sd[1], 0, 0);
-            av_dict_set(&p->metadata, "timecode", tcbuf, 0);
+                av_timecode_make_smpte_tc_string2(tcbuf, avctx->framerate,
+                                                  tc_sd[1], 0, 0);
+                av_dict_set(&p->metadata, "timecode", tcbuf, 0);
+            }
         }
     }