diff mbox series

[FFmpeg-devel,3/4] avformat/mxfenc: move content package rates and timebase combinations to a separate struct

Message ID 20200228003750.22536-3-cus@passwd.hu
State Superseded
Headers show
Series [FFmpeg-devel,1/4] avformat/audiointerleave: disallow using a samples_per_frame array | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Marton Balint Feb. 28, 2020, 12:37 a.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/mxf.c | 28 ++++++++++++----------------
 libavformat/mxf.h |  5 +++++
 2 files changed, 17 insertions(+), 16 deletions(-)

Comments

Tomas Härdin March 2, 2020, 5:50 p.m. UTC | #1
fre 2020-02-28 klockan 01:37 +0100 skrev Marton Balint:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavformat/mxf.c | 28 ++++++++++++----------------
>  libavformat/mxf.h |  5 +++++
>  2 files changed, 17 insertions(+), 16 deletions(-)
> 

Reasonable enough.

/Tomas
diff mbox series

Patch

diff --git a/libavformat/mxf.c b/libavformat/mxf.c
index 10ccd770e3..14056647c5 100644
--- a/libavformat/mxf.c
+++ b/libavformat/mxf.c
@@ -131,25 +131,21 @@  int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *
     return -1;
 }
 
-static const AVRational mxf_time_base[] = {
-    { 1001, 24000 },
-    { 1, 24},
-    { 1001, 30000 },
-    { 1001, 60000 },
-    { 1, 25 },
-    { 1, 50 },
-    { 1, 60 },
-    { 0, 0}
-};
-
-static const int mxf_content_package_rates[] = {
-    3, 2, 7, 13, 4, 10, 12,
+static const MXFContentPackageRate mxf_content_package_rates[] = {
+    {  2, { 1,    24    } },
+    {  3, { 1001, 24000 } },
+    {  4, { 1,    25    } },
+    {  7, { 1001, 30000 } },
+    { 10, { 1,    50    } },
+    { 12, { 1,    60    } },
+    { 13, { 1001, 60000 } },
+    {0}
 };
 
 int ff_mxf_get_content_package_rate(AVRational time_base)
 {
-    for (int i = 0; mxf_time_base[i].num; i++)
-        if (!av_cmp_q(time_base, mxf_time_base[i]))
-            return mxf_content_package_rates[i];
+    for (int i = 0; mxf_content_package_rates[i].rate; i++)
+        if (!av_cmp_q(time_base, mxf_content_package_rates[i].tb))
+            return mxf_content_package_rates[i].rate;
     return 0;
 }
diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index 2669269830..f2fff2781e 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -59,6 +59,11 @@  enum MXFFrameLayout {
     SegmentedFrame,
 };
 
+typedef struct MXFContentPackageRate {
+    int rate;
+    AVRational tb;
+} MXFContentPackageRate;
+
 typedef struct KLVPacket {
     UID key;
     int64_t offset;