[FFmpeg-devel] [PATCH]lavc/mjpeg2jpeg: Accept more mjpeg streams as input

Carl Eugen Hoyos cehoyos at ag.or.at
Tue Jan 12 16:18:35 CET 2016


On Tuesday 12 January 2016 03:19:24 pm Michael Niedermayer wrote:
> >  mjpeg2jpeg_bsf.c |    5 +++++
> >  1 file changed, 5 insertions(+)
> > a261f4350cbfeefc9c011cfc93fc39e5c4f7fe7c  patchmjpeg2jpgffd8.diff
> > diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
>
> LGTM

Patch applied.

New patch attached that fixes ticket #5151.

Thank you, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
index 71f0154..92dc3ca 100644
--- a/libavcodec/mjpeg2jpeg_bsf.c
+++ b/libavcodec/mjpeg2jpeg_bsf.c
@@ -32,6 +32,7 @@
 
 #include "avcodec.h"
 #include "jpegtables.h"
+#include "mjpeg.h"
 
 static const uint8_t jpeg_header[] = {
     0xff, 0xd8,                     // SOI
@@ -93,11 +94,11 @@ static int mjpeg2jpeg_filter(AVBitStreamFilterContext *bsfc,
         av_log(avctx, AV_LOG_ERROR, "input is not MJPEG\n");
         return AVERROR_INVALIDDATA;
     }
-    if (memcmp("AVI1", buf + 6, 4)) {
-        av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
-        return AVERROR_INVALIDDATA;
+    if (buf[2] == 0xff && buf[3] == APP0) {
+        input_skip = (buf[4] << 8) + buf[5] + 4;
+    } else {
+        input_skip = 2;
     }
-    input_skip = (buf[4] << 8) + buf[5] + 4;
     if (buf_size < input_skip) {
         av_log(avctx, AV_LOG_ERROR, "input is truncated\n");
         return AVERROR_INVALIDDATA;


More information about the ffmpeg-devel mailing list