From: Jerome Martinez via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: Jerome Martinez <jerome@mediaarea.net> Subject: [FFmpeg-devel] [PATCH 6/7] matroskadec: read timecode in BlockAddition Date: Tue, 9 Sep 2025 14:41:39 +0200 Message-ID: <64007e4f-bdb2-47f9-b50d-418584ac16a7@mediaarea.net> (raw) In-Reply-To: <d65a0f50-3766-4539-b140-55d7ac12810d@mediaarea.net> [-- Attachment #1: 0006-matroskadec-read-timecode-in-BlockAddition.patch --] [-- Type: text/plain, Size: 3448 bytes --] >From 887508f9f4e4ab21431a41cc78bea48039811cba Mon Sep 17 00:00:00 2001 From: Jerome Martinez <jerome@mediaarea.net> Date: Thu, 4 Sep 2025 20:17:55 +0200 Subject: [PATCH 6/7] matroskadec: read timecode in BlockAddition --- libavformat/matroska.h | 1 + libavformat/matroskadec.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 719f2ef796..d78b33d4b2 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -361,6 +361,7 @@ typedef enum { MATROSKA_BLOCK_ADD_ID_TYPE_DEFAULT = 0, MATROSKA_BLOCK_ADD_ID_TYPE_OPAQUE = 1, MATROSKA_BLOCK_ADD_ID_TYPE_ITU_T_T35 = 4, + MATROSKA_BLOCK_ADD_ID_TYPE_SMPTE_12M = 121, MATROSKA_BLOCK_ADD_ID_TYPE_DVCC = 0x64766343, // MKBETAG('d','v','c','C') MATROSKA_BLOCK_ADD_ID_TYPE_DVVC = 0x64767643, // MKBETAG('d','v','v','C') } MatroskaBlockAddIDType; diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 1e0c75c51b..d8800b48a6 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -295,6 +295,7 @@ typedef struct MatroskaTrack { uint32_t palette[AVPALETTE_COUNT]; int has_palette; + int add_block_timecode_count; } MatroskaTrack; typedef struct MatroskaAttachment { @@ -2530,6 +2531,9 @@ static int mkv_parse_block_addition_mappings(AVFormatContext *s, AVStream *st, M return AVERROR_INVALIDDATA; } break; + case MATROSKA_BLOCK_ADD_ID_TYPE_SMPTE_12M: + track->add_block_timecode_count++; + break; case MATROSKA_BLOCK_ADD_ID_TYPE_DVCC: case MATROSKA_BLOCK_ADD_ID_TYPE_DVVC: if ((ret = mkv_parse_dvcc_dvvc(s, st, track, &mapping->extradata)) < 0) @@ -3954,6 +3958,36 @@ static int matroska_parse_block_additional(MatroskaDemuxContext *matroska, return 0; } + case MATROSKA_BLOCK_ADD_ID_TYPE_SMPTE_12M: { + if (size < 8) { + av_log(matroska->ctx, AV_LOG_WARNING, "SMPTE timecode from BlockAdditional is malformed.\n"); + break; + } + + size_t sd_size = 0; + uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_S12M_TIMECODE, &sd_size); + uint64_t count = sd ? *((uint64_t*)sd) : 0; + if (!count) { + sd_size = sizeof(uint64_t) * (1 + track->add_block_timecode_count); + sd = av_packet_new_side_data(pkt, AV_PKT_DATA_S12M_TIMECODE, sd_size); + count = 0; + } + + if (count >= track->add_block_timecode_count) { + av_log(matroska->ctx, AV_LOG_DEBUG, "There are more timecodes in the block than the count indicated in the track header, extra timecodes are ignored.\n"); + } + else if (sd) { + uint64_t tc = *((uint64_t*)data); + av_log(matroska->ctx, AV_LOG_DEBUG, "Reading SMPTE timecode from BlockAdditional: 0x%016lX (RFC 5484)\n", tc); + + uint64_t *sd_64 = (uint64_t*)sd; + count++; + *sd_64 = count; + AV_WB64(sd_64 + count, tc); + } + + return 0; + } default: break; } -- 2.46.0.windows.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
next prev parent reply other threads:[~2025-09-09 12:42 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-09-09 12:37 [FFmpeg-devel] [PATCH 0/7] matroska: support of timecode Jerome Martinez via ffmpeg-devel 2025-09-09 12:38 ` [FFmpeg-devel] [PATCH 1/7] matroskaenc: remove unused MaxBlockAdditionID Jerome Martinez via ffmpeg-devel 2025-09-09 12:39 ` [FFmpeg-devel] [PATCH 2/7] matroskaenc: reserve_video_track_space option Jerome Martinez via ffmpeg-devel 2025-09-09 12:39 ` [FFmpeg-devel] [PATCH 3/7] matroskaenc: increase default for reserved bytes in video Jerome Martinez via ffmpeg-devel 2025-09-09 12:40 ` [FFmpeg-devel] [PATCH 4/7] 32-bit timecode to 64-bit RFC 5484 timecode functions Jerome Martinez via ffmpeg-devel 2025-09-09 12:41 ` [FFmpeg-devel] [PATCH 5/7] decklink_dec: store timecode in 64-bit RFC 5484 format Jerome Martinez via ffmpeg-devel 2025-09-09 12:41 ` Jerome Martinez via ffmpeg-devel [this message] 2025-09-09 12:41 ` [FFmpeg-devel] [PATCH 7/7] matroskaenc: write timecode in BlockAddition Jerome Martinez via ffmpeg-devel 2025-09-11 15:52 ` [FFmpeg-devel] Re: [PATCH 0/7] matroska: support of timecode Dave Rice via ffmpeg-devel
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=64007e4f-bdb2-47f9-b50d-418584ac16a7@mediaarea.net \ --to=ffmpeg-devel@ffmpeg.org \ --cc=jerome@mediaarea.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git