* [FFmpeg-devel] [PATCH] avformat/matroskadec: relax the check for cropped dimensions (PR #20653)
@ 2025-10-06 13:26 James Almer via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: James Almer via ffmpeg-devel @ 2025-10-06 13:26 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: James Almer
PR #20653 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20653
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20653.patch
There seem to be samples with no Video element on video tracks in the wild, which even if not spec compliant, can be demuxed fine after lavf probes the stream with a decoder/parser.
Relax the check to allow tracks with no dimensions to work, and also add a check for strict spec compliance to maintain the current behavior if desired.
Fixes issue #20649.
>From 0de01622dd901e78a1d6a4faef0f18afba537667 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Mon, 6 Oct 2025 10:21:03 -0300
Subject: [PATCH] avformat/matroskadec: relax the check for cropped dimensions
There seem to be samples with no Video element on video tracks in the wild,
which even if not spec compliant, can be demuxed fine after lavf probes the
stream with a decoder/parser.
Relax the check to allow tracks with no dimensions to work, and also add a
check for strict spec compliance to maintain the current behavior if desired.
Fixes issue #20649.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavformat/matroskadec.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 6c12e1594c..c4190cc059 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3168,10 +3168,13 @@ static int matroska_parse_tracks(AVFormatContext *s)
track->default_duration = default_duration;
}
}
+ if (matroska->ctx->strict_std_compliance >= FF_COMPLIANCE_STRICT &&
+ (!track->video.pixel_width || !track->video.pixel_height))
+ return AVERROR_INVALIDDATA;
if (track->video.pixel_cropl >= INT_MAX - track->video.pixel_cropr ||
track->video.pixel_cropt >= INT_MAX - track->video.pixel_cropb ||
- (track->video.pixel_cropl + track->video.pixel_cropr) >= track->video.pixel_width ||
- (track->video.pixel_cropt + track->video.pixel_cropb) >= track->video.pixel_height)
+ (track->video.pixel_cropl + track->video.pixel_cropr) >= track->video.pixel_width + !track->video.pixel_width ||
+ (track->video.pixel_cropt + track->video.pixel_cropb) >= track->video.pixel_height + !track->video.pixel_height)
return AVERROR_INVALIDDATA;
track->video.cropped_width = track->video.pixel_width -
track->video.pixel_cropl - track->video.pixel_cropr;
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-10-06 13:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-06 13:26 [FFmpeg-devel] [PATCH] avformat/matroskadec: relax the check for cropped dimensions (PR #20653) James Almer via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ http://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git