[FFmpeg-devel] [PATCH 07/16] avformat/mxf: Deduplicate random_index_pack_key

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Mon Jan 4 02:28:07 EET 2021


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
There is also another key that is duplicated: header_open_partition_key
and mxf_jp2k_rsiz. But they seem to mean something different which makes
me wonder if one of these keys is incorrect; I have therefore refrained
from deduplicating them.

 libavformat/mxf.c    | 2 ++
 libavformat/mxf.h    | 1 +
 libavformat/mxfdec.c | 3 +--
 libavformat/mxfenc.c | 3 +--
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/mxf.c b/libavformat/mxf.c
index 88f69ebcfb..1901b24c68 100644
--- a/libavformat/mxf.c
+++ b/libavformat/mxf.c
@@ -24,6 +24,8 @@
 
 const uint8_t ff_mxf_mastering_display_prefix[13]           = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01 };
 
+const uint8_t ff_mxf_random_index_pack_key[16] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 };
+
 /* be careful to update references to this array if reordering */
 /* local tags are dynamic and must not clash with others in mxfenc.c */
 const MXFLocalTagPair ff_mxf_mastering_display_local_tags[4] = {
diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index 7fa10bcca1..5219abc767 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -84,6 +84,7 @@ typedef struct MXFLocalTagPair {
 } MXFLocalTagPair;
 
 extern const uint8_t ff_mxf_mastering_display_prefix[13];
+extern const uint8_t ff_mxf_random_index_pack_key[16];
 extern const MXFLocalTagPair ff_mxf_mastering_display_local_tags[4];
 
 #define FF_MXF_MASTERING_CHROMA_DEN 50000
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index b563f2abe1..784f43d6d1 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -328,7 +328,6 @@ static const uint8_t mxf_apple_coll_prefix[]               = { 0x06,0x0e,0x2b,0x
 static const uint8_t mxf_crypto_source_container_ul[]      = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 };
 static const uint8_t mxf_encrypted_triplet_key[]           = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
 static const uint8_t mxf_encrypted_essence_container[]     = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
-static const uint8_t mxf_random_index_pack_key[]           = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 };
 static const uint8_t mxf_sony_mpeg4_extradata[]            = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
 static const uint8_t mxf_avid_project_name[]               = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf };
 static const uint8_t mxf_jp2k_rsiz[]                       = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 };
@@ -3264,7 +3263,7 @@ static void mxf_read_random_index_pack(AVFormatContext *s)
         goto end;
     avio_seek(s->pb, file_size - length, SEEK_SET);
     if (klv_read_packet(&klv, s->pb) < 0 ||
-        !IS_KLV_KEY(klv.key, mxf_random_index_pack_key))
+        !IS_KLV_KEY(klv.key, ff_mxf_random_index_pack_key))
         goto end;
     if (klv.next_klv != file_size || klv.length <= 4 || (klv.length - 4) % 12) {
         av_log(s, AV_LOG_WARNING, "Invalid RIP KLV length\n");
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index d8678c9d25..6c5331ad62 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -271,7 +271,6 @@ static const uint8_t opatom_ul[]                   = { 0x06,0x0E,0x2B,0x34,0x04,
 static const uint8_t footer_partition_key[]        = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x04,0x04,0x00 }; // ClosedComplete
 static const uint8_t primer_pack_key[]             = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x05,0x01,0x00 };
 static const uint8_t index_table_segment_key[]     = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 };
-static const uint8_t random_index_pack_key[]       = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x11,0x01,0x00 };
 static const uint8_t header_open_partition_key[]   = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }; // OpenIncomplete
 static const uint8_t header_closed_partition_key[] = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x02,0x04,0x00 }; // ClosedComplete
 static const uint8_t klv_fill_key[]                = { 0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x01,0x02,0x10,0x01,0x00,0x00,0x00 };
@@ -2956,7 +2955,7 @@ static void mxf_write_random_index_pack(AVFormatContext *s)
     uint64_t pos = avio_tell(pb);
     int i;
 
-    avio_write(pb, random_index_pack_key, 16);
+    avio_write(pb, ff_mxf_random_index_pack_key, 16);
     klv_encode_ber_length(pb, 28 + 12LL*mxf->body_partitions_count);
 
     if (mxf->edit_unit_byte_count && s->oformat != &ff_mxf_opatom_muxer)
-- 
2.25.1



More information about the ffmpeg-devel mailing list