[FFmpeg-devel] [PATCH] img2enc: remove nonsense broken code

Paul B Mahol onemda at gmail.com
Mon Nov 5 21:15:36 CET 2012


split_planes: this is awfull hack and if it is ever triggered it can
not work correctly for almost all image format and may cause invalid reads.

jp2 hack: nothing use this and this is not right place for it.
It also does not work reliably (it use filename to guess codec).

Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavformat/img2enc.c | 39 ---------------------------------------
 1 file changed, 39 deletions(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index dea4572..6d601ba 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -33,7 +33,6 @@ typedef struct {
     const AVClass *class;  /**< Class for private options. */
     int img_number;
     int is_pipe;
-    int split_planes;       /**< use independent file for each Y, U, V plane */
     char path[1024];
     int updatefirst;
 } VideoMuxData;
@@ -52,7 +51,6 @@ static int write_header(AVFormatContext *s)
         img->is_pipe = 1;
 
     str = strrchr(img->path, '.');
-    img->split_planes = str && !av_strcasecmp(str + 1, "y");
     return 0;
 }
 
@@ -79,49 +77,12 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
                 return AVERROR(EIO);
             }
 
-            if(!img->split_planes)
-                break;
             filename[ strlen(filename) - 1 ]= 'U' + i;
         }
     } else {
         pb[0] = s->pb;
     }
 
-    if(img->split_planes){
-        int ysize = codec->width * codec->height;
-        avio_write(pb[0], pkt->data        , ysize);
-        avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);
-        avio_write(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2);
-        avio_close(pb[1]);
-        avio_close(pb[2]);
-    }else{
-        if(ff_guess_image2_codec(s->filename) == AV_CODEC_ID_JPEG2000){
-            AVStream *st = s->streams[0];
-            if(st->codec->extradata_size > 8 &&
-               AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){
-                if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c'))
-                    goto error;
-                avio_wb32(pb[0], 12);
-                ffio_wfourcc(pb[0], "jP  ");
-                avio_wb32(pb[0], 0x0D0A870A); // signature
-                avio_wb32(pb[0], 20);
-                ffio_wfourcc(pb[0], "ftyp");
-                ffio_wfourcc(pb[0], "jp2 ");
-                avio_wb32(pb[0], 0);
-                ffio_wfourcc(pb[0], "jp2 ");
-                avio_write(pb[0], st->codec->extradata, st->codec->extradata_size);
-            }else if(pkt->size >= 8 && AV_RB32(pkt->data) == 0xFF4FFF51){
-                //jpeg2000 codestream
-            }else if(pkt->size < 8 ||
-                     (!st->codec->extradata_size &&
-                      AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature
-            error:
-                av_log(s, AV_LOG_ERROR, "malformed JPEG 2000 codestream %X\n", AV_RB32(pkt->data));
-                return -1;
-            }
-        }
-        avio_write(pb[0], pkt->data, pkt->size);
-    }
     avio_flush(pb[0]);
     if (!img->is_pipe) {
         avio_close(pb[0]);
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list