Hi Jerome

On Tue, Sep 09, 2025 at 02:41:39PM +0200, Jerome Martinez via ffmpeg-devel 
wrote:
>  matroska.h    |    1 +
>  matroskadec.c |   34 ++++++++++++++++++++++++++++++++++
>  2 files changed, 35 insertions(+)
> 83b42253e7a0ca4f220f658b0671e4056e719592  
> 0006-matroskadec-read-timecode-in-BlockAddition.patch
> >From 887508f9f4e4ab21431a41cc78bea48039811cba Mon Sep 17 00:00:00 2001
> From: Jerome Martinez <jer...@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;

count is already 0 here


> +        }
> +
> +        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);

is this aligned correctly for uint64_t ?


> +            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);
> +        }
> +        

Trailing whitespace


> +        return 0;
> +    }

the {} is unneeded

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras

Attachment: signature.asc
Description: PGP signature

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-le...@ffmpeg.org

Reply via email to