[FFmpeg-devel] [PATCH] avformat/mxfdec: only check index_edit_rate when calculating the index tables

Marton Balint cus at passwd.hu
Mon Apr 15 22:34:00 EEST 2024


Commit ed49391961999f028e0bc55767d0eef6eeb15e49 started rejecting negative
index segment edit rates to avoid negative av_rescale parameters. There are two
problems with this:

1) there is already a validation for zero (uninitialized) rates later on
2) it rejects files with 0/0 index edit rates which do exist and we should
continue to support those

Let's solve these problems by removing the new check and extending the old
check for negative index edit rates. This should fix the original issue and
also restore support for 0/0 index edit rates.

Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavformat/mxfdec.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 233d614f78..71692c36bd 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1264,9 +1264,6 @@ static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int
     case 0x3F0B:
         segment->index_edit_rate.num = avio_rb32(pb);
         segment->index_edit_rate.den = avio_rb32(pb);
-        if (segment->index_edit_rate.num <= 0 ||
-            segment->index_edit_rate.den <= 0)
-            return AVERROR_INVALIDDATA;
         av_log(NULL, AV_LOG_TRACE, "IndexEditRate %d/%d\n", segment->index_edit_rate.num,
                 segment->index_edit_rate.den);
         break;
@@ -2135,7 +2132,7 @@ static int mxf_compute_index_tables(MXFContext *mxf)
 
         /* fix zero IndexDurations */
         for (k = 0; k < t->nb_segments; k++) {
-            if (!t->segments[k]->index_edit_rate.num || !t->segments[k]->index_edit_rate.den) {
+            if (t->segments[k]->index_edit_rate.num <= 0 || t->segments[k]->index_edit_rate.den <= 0) {
                 av_log(mxf->fc, AV_LOG_WARNING, "IndexSID %i segment %i has invalid IndexEditRate\n",
                        t->index_sid, k);
                 if (mxf_track)
-- 
2.35.3



More information about the ffmpeg-devel mailing list