[FFmpeg-devel] [PATCH]Make ljpeg decoding opaque

Carl Eugen Hoyos cehoyos at ag.or.at
Tue Dec 6 02:17:04 CET 2011


Hi!

Attached patch stops ljpeg pictures from being transparent after decoding.
Is the first hunk useful?
Is the correct solution to decode them to RGB24?

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 7e69f28..a9d7fe1 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -324,7 +324,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
     switch(pix_fmt_id){
     case 0x11111100:
         if(s->rgb){
-            s->avctx->pix_fmt = PIX_FMT_BGRA;
+            s->avctx->pix_fmt = PIX_FMT_BGR0;
         }else{
             if(s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A'){
                 s->avctx->pix_fmt = PIX_FMT_GBR24P;
@@ -690,18 +690,21 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int predictor, int point
                 ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200)>>2);
                 ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
                 ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
+                ptr[4*mb_x+3] = 0xFF;
             }
         }else if(s->pegasus_rct){
             for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
                 ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2])>>2);
                 ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
                 ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
+                ptr[4*mb_x+3] = 0xFF;
             }
         }else{
             for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
                 ptr[4*mb_x+0] = buffer[mb_x][2];
                 ptr[4*mb_x+1] = buffer[mb_x][1];
                 ptr[4*mb_x+2] = buffer[mb_x][0];
+                ptr[4*mb_x+3] = 0xFF;
             }
         }
     }


More information about the ffmpeg-devel mailing list