diff mbox series

[FFmpeg-devel,12/14] avformat/matroskasem: reorder some EbmlSyntax elements

Message ID 20200322085933.7532-12-robUx4@ycbcr.xyz
State New
Headers show
Series [FFmpeg-devel,01/14] avformat/matroska: add missing Buttons track type
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Steve Lhomme March 22, 2020, 8:59 a.m. UTC
From: Steve Lhomme <robux4@ycbcr.xyz>

So it's easier to match with the XSLT ordering which has limited possibilities
(15 max criteria for all the syntax tables).

No functional changes.
---
 libavformat/matroskasem.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Comments

Andreas Rheinhardt April 8, 2020, 5:47 p.m. UTC | #1
Steve Lhomme:
> From: Steve Lhomme <robux4@ycbcr.xyz>
> 
> So it's easier to match with the XSLT ordering which has limited possibilities
> (15 max criteria for all the syntax tables).
> 
I don't know XSLT at all, but this already raises alarm bells: If this
is so restricted, then this whole approach might be a non-extensible
dead-end.
(I e.g. pondered to remove all those EBML_NONE elements that are not
read at all at the moment from the syntax tables and instead add a
pointer to a zero-delimited array of uint32_t that contains all* the
EBML IDs of elements that may legitimately appear in said context, but
which we don't care about (yet). (Both list_elem_size as well as
data_offset of the sentinels are currently unused, so sizeof(EbmlSyntax)
needn't be increased for this.) Would this even be possible with your
approach?)

- Andreas

*: The current tables don't include all these elements.
diff mbox series

Patch

diff --git a/libavformat/matroskasem.c b/libavformat/matroskasem.c
index 27aa6d9c4e..aca506b943 100644
--- a/libavformat/matroskasem.c
+++ b/libavformat/matroskasem.c
@@ -101,10 +101,6 @@  EbmlSyntax matroska_track_video[] = {
     { MATROSKA_ID_VIDEODISPLAYHEIGHT,  EBML_UINT,  0, offsetof(MatroskaTrackVideo, display_height), { .u=-1 } },
     { MATROSKA_ID_VIDEOPIXELWIDTH,     EBML_UINT,  0, offsetof(MatroskaTrackVideo, pixel_width) },
     { MATROSKA_ID_VIDEOPIXELHEIGHT,    EBML_UINT,  0, offsetof(MatroskaTrackVideo, pixel_height) },
-    { MATROSKA_ID_VIDEOCOLORSPACE,     EBML_BIN,   0, offsetof(MatroskaTrackVideo, color_space) },
-    { MATROSKA_ID_VIDEOALPHAMODE,      EBML_UINT,  0, offsetof(MatroskaTrackVideo, alpha_mode) },
-    { MATROSKA_ID_VIDEOCOLOR,          EBML_NEST,  sizeof(MatroskaTrackVideoColor), offsetof(MatroskaTrackVideo, color), { .n = matroska_track_video_color } },
-    { MATROSKA_ID_VIDEOPROJECTION,     EBML_NEST,  0, offsetof(MatroskaTrackVideo, projection), { .n = matroska_track_video_projection } },
     { MATROSKA_ID_VIDEOPIXELCROPB,     EBML_NONE },
     { MATROSKA_ID_VIDEOPIXELCROPT,     EBML_NONE },
     { MATROSKA_ID_VIDEOPIXELCROPL,     EBML_NONE },
@@ -112,6 +108,10 @@  EbmlSyntax matroska_track_video[] = {
     { MATROSKA_ID_VIDEODISPLAYUNIT,    EBML_UINT,  0, offsetof(MatroskaTrackVideo, display_unit), { .u= MATROSKA_VIDEO_DISPLAYUNIT_PIXELS } },
     { MATROSKA_ID_VIDEOFLAGINTERLACED, EBML_UINT,  0, offsetof(MatroskaTrackVideo, interlaced),  { .u = MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED } },
     { MATROSKA_ID_VIDEOFIELDORDER,     EBML_UINT,  0, offsetof(MatroskaTrackVideo, field_order), { .u = MATROSKA_VIDEO_FIELDORDER_UNDETERMINED } },
+    { MATROSKA_ID_VIDEOALPHAMODE,      EBML_UINT,  0, offsetof(MatroskaTrackVideo, alpha_mode) },
+    { MATROSKA_ID_VIDEOCOLORSPACE,     EBML_BIN,   0, offsetof(MatroskaTrackVideo, color_space) },
+    { MATROSKA_ID_VIDEOCOLOR,          EBML_NEST,  sizeof(MatroskaTrackVideoColor), offsetof(MatroskaTrackVideo, color), { .n = matroska_track_video_color } },
+    { MATROSKA_ID_VIDEOPROJECTION,     EBML_NEST,  0, offsetof(MatroskaTrackVideo, projection), { .n = matroska_track_video_projection } },
     { MATROSKA_ID_VIDEOSTEREOMODE,     EBML_UINT,  0, offsetof(MatroskaTrackVideo, stereo_mode), { .u = MATROSKA_VIDEO_STEREOMODE_TYPE_NB } },
     { MATROSKA_ID_VIDEOASPECTRATIO,    EBML_NONE },
     CHILD_OF(matroska_track)
@@ -187,18 +187,18 @@  EbmlSyntax matroska_track[] = {
     { MATROSKA_ID_TRACKFLAGFORCED,       EBML_UINT,  0, offsetof(MatroskaTrack, flag_forced) },
     { MATROSKA_ID_TRACKVIDEO,            EBML_NEST,  0, offsetof(MatroskaTrack, video),        { .n = matroska_track_video } },
     { MATROSKA_ID_TRACKAUDIO,            EBML_NEST,  0, offsetof(MatroskaTrack, audio),        { .n = matroska_track_audio } },
-    { MATROSKA_ID_TRACKOPERATION,        EBML_NEST,  0, offsetof(MatroskaTrack, operation),    { .n = matroska_track_operation } },
-    { MATROSKA_ID_TRACKCONTENTENCODINGS, EBML_NEST,  0, 0,                                     { .n = matroska_track_encodings } },
-    { MATROSKA_ID_TRACKMAXBLKADDID,      EBML_UINT,  0, offsetof(MatroskaTrack, max_block_additional_id) },
-    { MATROSKA_ID_SEEKPREROLL,           EBML_UINT,  0, offsetof(MatroskaTrack, seek_preroll) },
     { MATROSKA_ID_TRACKFLAGENABLED,      EBML_NONE },
     { MATROSKA_ID_TRACKFLAGLACING,       EBML_NONE },
+    { MATROSKA_ID_TRACKMINCACHE,         EBML_NONE },
+    { MATROSKA_ID_TRACKMAXCACHE,         EBML_NONE },
+    { MATROSKA_ID_TRACKMAXBLKADDID,      EBML_UINT,  0, offsetof(MatroskaTrack, max_block_additional_id) },
     { MATROSKA_ID_CODECNAME,             EBML_NONE },
-    { MATROSKA_ID_CODECDECODEALL,        EBML_NONE },
     { MATROSKA_ID_CODECINFOURL,          EBML_NONE },
     { MATROSKA_ID_CODECDOWNLOADURL,      EBML_NONE },
-    { MATROSKA_ID_TRACKMINCACHE,         EBML_NONE },
-    { MATROSKA_ID_TRACKMAXCACHE,         EBML_NONE },
+    { MATROSKA_ID_CODECDECODEALL,        EBML_NONE },
+    { MATROSKA_ID_SEEKPREROLL,           EBML_UINT,  0, offsetof(MatroskaTrack, seek_preroll) },
+    { MATROSKA_ID_TRACKOPERATION,        EBML_NEST,  0, offsetof(MatroskaTrack, operation),    { .n = matroska_track_operation } },
+    { MATROSKA_ID_TRACKCONTENTENCODINGS, EBML_NEST,  0, 0,                                     { .n = matroska_track_encodings } },
     CHILD_OF(matroska_tracks)
 };
 
@@ -307,10 +307,10 @@  EbmlSyntax matroska_cluster_parsing[] = {
     { MATROSKA_ID_SIMPLEBLOCK,     EBML_BIN,  0, offsetof(MatroskaBlock, bin) },
     { MATROSKA_ID_BLOCKGROUP,      EBML_NEST, 0, 0, { .n = matroska_blockgroup } },
     { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0, offsetof(MatroskaCluster, timecode) },
-    { MATROSKA_ID_SIMPLEBLOCK,     EBML_STOP },
-    { MATROSKA_ID_BLOCKGROUP,      EBML_STOP },
     { MATROSKA_ID_CLUSTERPOSITION, EBML_NONE },
     { MATROSKA_ID_CLUSTERPREVSIZE, EBML_NONE },
+    { MATROSKA_ID_SIMPLEBLOCK,     EBML_STOP },
+    { MATROSKA_ID_BLOCKGROUP,      EBML_STOP },
     CHILD_OF(matroska_segment)
 };