diff mbox series

[FFmpeg-devel] avformat/mxfdec: treat Random Index Pack as end of file

Message ID 20230326211423.2455-1-cus@passwd.hu
State Accepted
Commit 8f534618b5acfb40f146651ba2a3b88fc00eb8b9
Headers show
Series [FFmpeg-devel] avformat/mxfdec: treat Random Index Pack as end of file | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Marton Balint March 26, 2023, 9:14 p.m. UTC
RIP, if exists is the last KLV item in the MXF files therefore we can stop
parsing the file if it is encountered. This allows us to support files created by
broken muxers such as OpenCube MXFTk Advanced 2.8.0.0.1. which dumps some extra
garbage after the RIP.

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

Comments

Marton Balint April 2, 2023, 7:33 p.m. UTC | #1
On Sun, 26 Mar 2023, Marton Balint wrote:

> RIP, if exists is the last KLV item in the MXF files therefore we can stop
> parsing the file if it is encountered. This allows us to support files created by
> broken muxers such as OpenCube MXFTk Advanced 2.8.0.0.1. which dumps some extra
> garbage after the RIP.

Will apply soon.

Regards,
Marton

>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavformat/mxfdec.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 4530617207..8a7008b298 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -3739,7 +3739,10 @@ static int mxf_read_header(AVFormatContext *s)
>     while (!avio_feof(s->pb)) {
>         const MXFMetadataReadTableEntry *metadata;
>
> -        if (klv_read_packet(&klv, s->pb) < 0) {
> +        ret = klv_read_packet(&klv, s->pb);
> +        if (ret < 0 || IS_KLV_KEY(klv.key, ff_mxf_random_index_pack_key)) {
> +            if (ret >= 0 && avio_size(s->pb) > klv.next_klv)
> +                av_log(s, AV_LOG_WARNING, "data after the RandomIndexPack, assuming end of file\n");
>             /* EOF - seek to previous partition or stop */
>             if(mxf_parse_handle_partition_or_eof(mxf) <= 0)
>                 break;
> -- 
> 2.35.3
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Tomas Härdin April 5, 2023, 12:59 p.m. UTC | #2
sön 2023-03-26 klockan 23:14 +0200 skrev Marton Balint:
> RIP, if exists is the last KLV item in the MXF files therefore we can
> stop
> parsing the file if it is encountered. This allows us to support
> files created by
> broken muxers such as OpenCube MXFTk Advanced 2.8.0.0.1. which dumps
> some extra
> garbage after the RIP.
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavformat/mxfdec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Looks OK

/Tomas
diff mbox series

Patch

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 4530617207..8a7008b298 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -3739,7 +3739,10 @@  static int mxf_read_header(AVFormatContext *s)
     while (!avio_feof(s->pb)) {
         const MXFMetadataReadTableEntry *metadata;
 
-        if (klv_read_packet(&klv, s->pb) < 0) {
+        ret = klv_read_packet(&klv, s->pb);
+        if (ret < 0 || IS_KLV_KEY(klv.key, ff_mxf_random_index_pack_key)) {
+            if (ret >= 0 && avio_size(s->pb) > klv.next_klv)
+                av_log(s, AV_LOG_WARNING, "data after the RandomIndexPack, assuming end of file\n");
             /* EOF - seek to previous partition or stop */
             if(mxf_parse_handle_partition_or_eof(mxf) <= 0)
                 break;