[FFmpeg-devel] [PATCH]lavc/mjpeg2jpeg: Accept more mjpeg streams as input
Michael Niedermayer
michael at niedermayer.cc
Tue Jan 12 14:16:52 CET 2016
On Tue, Jan 12, 2016 at 09:58:53AM +0100, Carl Eugen Hoyos wrote:
> Hi!
>
> I guess that attached patch fixes ticket #5151.
> It is the user's responsibility to know if the input stream
> is suitable for the bitstream filter or not.
>
> Please comment, Carl Eugen
> mjpeg2jpeg_bsf.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
> 6d36c24e50d0ba2484b959c5f315de919c57ae5f patchmjpeg2jpg.diff
> diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
> index 68640db..b29039e 100644
> --- a/libavcodec/mjpeg2jpeg_bsf.c
> +++ b/libavcodec/mjpeg2jpeg_bsf.c
> @@ -31,6 +31,7 @@
>
> #include "avcodec.h"
> #include "jpegtables.h"
> +#include "mjpeg.h"
>
> static const uint8_t jpeg_header[] = {
> 0xff, 0xd8, // SOI
> @@ -88,11 +89,11 @@ static int mjpeg2jpeg_filter(AVBitStreamFilterContext *bsfc,
> av_log(avctx, AV_LOG_ERROR, "input is truncated\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;
shouldnt the first 2 bytes that are being skiped be checked ?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160112/7fa5c942/attachment.sig>
More information about the ffmpeg-devel
mailing list