diff mbox series

[FFmpeg-devel,32/38] avcodec/mpeg12dec: use ff_frame_new_side_data

Message ID 20240223143115.16521-33-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/38] lavu/opt: cosmetics, change option flags to (1 << N) style | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Feb. 23, 2024, 1:58 p.m. UTC
From: Niklas Haas <git@haasn.dev>

For consistency, even though this cannot be overriden at the packet
level.
---
 libavcodec/mpeg12dec.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 96987f5a8e..1038a08637 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2532,15 +2532,17 @@  static int mpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture,
 
         if (s->timecode_frame_start != -1 && *got_output) {
             char tcbuf[AV_TIMECODE_STR_SIZE];
-            AVFrameSideData *tcside = av_frame_new_side_data(picture,
-                                                             AV_FRAME_DATA_GOP_TIMECODE,
-                                                             sizeof(int64_t));
-            if (!tcside)
-                return AVERROR(ENOMEM);
-            memcpy(tcside->data, &s->timecode_frame_start, sizeof(int64_t));
+            AVFrameSideData *tcside;
+            ret = ff_frame_new_side_data(avctx, picture, AV_FRAME_DATA_GOP_TIMECODE,
+                                         sizeof(int64_t), &tcside);
+            if (ret < 0)
+                return ret;
+            if (tcside) {
+                memcpy(tcside->data, &s->timecode_frame_start, sizeof(int64_t));
 
-            av_timecode_make_mpeg_tc_string(tcbuf, s->timecode_frame_start);
-            av_dict_set(&picture->metadata, "timecode", tcbuf, 0);
+                av_timecode_make_mpeg_tc_string(tcbuf, s->timecode_frame_start);
+                av_dict_set(&picture->metadata, "timecode", tcbuf, 0);
+            }
 
             s->timecode_frame_start = -1;
         }