Forget the old one. Refactored some variables to more appropriate locations as well.

Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 766dc9c46ed9d528d41505f8b67e18ef261f8f0e Mon Sep 17 00:00:00 2001
From: Mats Peterson <matsp...@yahoo.com>
Date: Tue, 8 Mar 2016 11:26:32 +0100
Subject: [PATCH 1/2] lavf/avienc: Palette changing code only concerns AV_PIX_FMT_PAL8

---
 libavformat/avienc.c |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 357dd34..ad50379 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -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);
-- 
1.7.10.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to