lavf/avienc: Palette changing code only concerns AV_PIX_FMT_PAL8
authorMats Peterson <matsp888@yahoo.com>
Tue, 8 Mar 2016 10:26:32 +0000 (11:26 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 8 Mar 2016 14:33:17 +0000 (15:33 +0100)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/avienc.c

index 357dd34..ad50379 100644 (file)
@@ -656,13 +656,8 @@ static int write_skip_frames(AVFormatContext *s, int stream_index, int64_t dts)
 
 static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    unsigned char tag[5];
     const int stream_index = pkt->stream_index;
-    AVIOContext *pb     = s->pb;
     AVCodecContext *enc = s->streams[stream_index]->codec;
-    AVIStream *avist    = s->streams[stream_index]->priv_data;
-    AVPacket *opkt = pkt;
-    enum AVPixelFormat pix_fmt = enc->pix_fmt;
     int ret;
 
     if (enc->codec_id == AV_CODEC_ID_H264 && enc->codec_tag == MKTAG('H','2','6','4') && pkt->size) {
@@ -678,6 +673,9 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
         return avi_write_packet_internal(s, pkt); /* Passthrough */
 
     if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+        AVIStream *avist = s->streams[stream_index]->priv_data;
+        AVIOContext *pb  = s->pb;
+        AVPacket *opkt   = pkt;
         if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0) {
             int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
             int expected_stride = ((enc->width * bpc + 31) >> 5)*4;
@@ -686,11 +684,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
                 return ret;
         } else
             ret = 0;
-        if (pix_fmt == AV_PIX_FMT_NONE && enc->bits_per_coded_sample == 1)
-            pix_fmt = AV_PIX_FMT_MONOWHITE;
-        if (pix_fmt == AV_PIX_FMT_PAL8 ||
-            pix_fmt == AV_PIX_FMT_MONOWHITE ||
-            pix_fmt == AV_PIX_FMT_MONOBLACK) {
+        if (enc->pix_fmt == AV_PIX_FMT_PAL8) {
             int ret2 = ff_get_packet_palette(s, opkt, ret, avist->palette);
             if (ret2 < 0)
                 return ret2;
@@ -712,6 +706,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
                     avist->pal_offset = 0;
                 }
                 if (memcmp(avist->palette, avist->old_palette, pal_size * 4)) {
+                    unsigned char tag[5];
                     avi_stream2fourcc(tag, stream_index, enc->codec_type);
                     tag[2] = 'p'; tag[3] = 'c';
                     pc_tag = ff_start_tag(pb, tag);