From 9e4225cf7f26b57e0054470127bcc032b6d29742 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 12 Dec 2020 15:09:10 +0100 Subject: Handle AVID MJPEG streams directly in the MJPEG decoder. AVID streams - currently handled by the AVRN decoder - can be (depending on extradata contents) either MJPEG or raw video. To decode the MJPEG variant, the AVRN decoder currently instantiates a MJPEG decoder internally and forwards decoded frames to the caller (possibly after cropping them). This is suboptimal, because the AVRN decoder does not forward all the features of the internal MJPEG decoder, such as direct rendering. Handling such forwarding in a full and generic manner would be quite hard, so it is simpler to just handle those streams in the MJPEG decoder directly. The AVRN decoder, which now handles only the raw streams, can now be marked as supporting direct rendering. This also removes the last remaining internal use of the obsolete decoding API. --- libavcodec/mjpegdec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libavcodec/mjpegdec.c') diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 256393a68f..79c7d6e6cf 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -450,6 +450,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) size_change = 0; } + if ((s->avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') || + s->avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) && + s->orig_height < s->avctx->height) + s->avctx->height = s->orig_height; + if (s->avctx->codec_id == AV_CODEC_ID_SMVJPEG) { s->avctx->height = s->avctx->coded_height / s->smv_frames_per_jpeg; if (s->avctx->height <= 0) @@ -2855,6 +2860,12 @@ the_end: return ret; } } + if ((avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') || + avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) && + avctx->coded_height > s->orig_height) { + frame->height = avctx->coded_height; + frame->crop_top = frame->height - s->orig_height; + } ret = 0; -- cgit v1.2.3