This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch release/9.0
in repository ffmpeg.

commit 330b026202985f37cb9657a7b82cf3b05144e1c1
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Sun Jul 26 23:07:35 2026 +0200
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Mon Aug 3 21:51:31 2026 +0200

    avcodec/utils: add ff_alloc_timecode_metadata_av1()
    
    (cherry picked from commit 5589dfd9bc0153f9c29832f39bfe1989ebf5f5aa)
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/internal.h |  3 +++
 libavcodec/utils.c    | 31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 137fd52745..e742b170cf 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -184,6 +184,9 @@ int avpriv_codec_get_cap_skip_frame_fill_param(const 
AVCodec *codec);
 int ff_alloc_timecode_sei(const AVFrame *frame, AVRational rate, size_t 
prefix_len,
                      void **data, size_t *sei_size);
 
+int ff_alloc_timecode_metadata_av1(const AVFrame *frame, AVRational rate,
+                                   void **data, size_t *size);
+
 /**
  * Get an estimated video bitrate based on frame size, frame rate and coded
  * bits per pixel.
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 5ac20c6a5e..cb6cf2d6a1 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1041,6 +1041,37 @@ int ff_alloc_timecode_sei(const AVFrame *frame, 
AVRational rate, size_t prefix_l
     return 0;
 }
 
+int ff_alloc_timecode_metadata_av1(const AVFrame *frame, AVRational rate,
+                                   void **data, size_t *size)
+{
+    AVFrameSideData *sd = NULL;
+    PutBitContext pb;
+    uint32_t *tc;
+
+    if (frame)
+        sd = av_frame_get_side_data(frame, AV_FRAME_DATA_S12M_TIMECODE);
+
+    *data = NULL;
+    if (!sd)
+        return 0;
+    tc = (uint32_t*)sd->data;
+    if (!(tc[0] & 3)) // num_clock_ts
+        return 0;
+
+    *size = 5;
+    *data = av_mallocz(*size);
+    if (!*data)
+        return AVERROR(ENOMEM);
+
+    init_put_bits(&pb, *data, *size);
+    put_timecode_fields(&pb, rate, tc[1]);
+    put_bits(&pb, 5, 1); // time_offset_length
+    put_bits(&pb, 1, 0); // time_offset_value
+    flush_put_bits(&pb);
+
+    return 0;
+}
+
 int64_t ff_guess_coded_bitrate(AVCodecContext *avctx)
 {
     AVRational framerate = avctx->framerate;

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to