Opened 13 years ago

Closed 13 years ago

#850 closed defect (fixed)

jpg: fix colors for sequential RGB

Reported by: ami_stuff Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: mjpeg gbr24p
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

this hack seems to solve the problem

mjpegdec.c:

           av_log(s->avctx, AV_LOG_ERROR, "decode_sos: index(%d) out of components\n", index);
            return -1;
        }
        /* Metasoft MJPEG codec has Cb and Cr swapped */
-        if (s->avctx->codec_tag == MKTAG('M', 'T', 'S', 'J')
-            && nb_components == 3 && s->nb_components == 3 && i)
            index = 3 - i;

        if(nb_components == 3 && s->nb_components == 3 && s->avctx->pix_fmt == PIX_FMT_GBR24P)
            index = (i+2)%3;

Attachments (1)

sequential_RGB_24bpp.jpg (222.6 KB ) - added by ami_stuff 13 years ago.

Download all attachments as: .zip

Change History (4)

by ami_stuff, 13 years ago

Attachment: sequential_RGB_24bpp.jpg added

comment:1 by ami_stuff, 13 years ago

C:\>ffmpeg -i equential_RGB_24bpp.jpg
ffmpeg version N-36193-gf514695, Copyright (c) 2000-2011 the FFmpeg developers
  built on Dec 26 2011 17:50:37 with gcc 4.6.2
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil      51. 33.100 / 51. 33.100
  libavcodec     53. 48.100 / 53. 48.100
  libavformat    53. 28.100 / 53. 28.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 54.100 /  2. 54.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  5.100 /  0.  5.100
  libpostproc    51.  2.100 / 51.  2.100
Input #0, image2, from 'sequential_RGB_24bpp.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: mjpeg, gbrp, 1024x768, 25 tbr, 25 tbn, 25 tbc
At least one output file must be specified

comment:2 by Carl Eugen Hoyos, 13 years ago

Component: undeterminedavcodec
Keywords: mjpeg gbr24p added
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

Above hack does not help, i is always 0 for this sample.

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 166c223..a439cff 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1018,6 +1018,8 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s,

         if(nb_components == 3 && s->nb_components == 3 && s->avctx->pix_fmt == PIX_FMT_GBR24P)
             index = (i+2)%3;
+        if(nb_components == 1 && s->avctx->pix_fmt == PIX_FMT_GBR24P)
+            index = (index+2)%3;

         s->comp_index[i] = index;


comment:3 by Michael Niedermayer, 13 years ago

Resolution: fixed
Status: openclosed

applied a modified version of carls patch

Note: See TracTickets for help on using tickets.