Commit e1aa88dc authored by Mats Peterson's avatar Mats Peterson Committed by Michael Niedermayer

lavf/avienc: Palette changing code only concerns AV_PIX_FMT_PAL8

Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent fd0c9789
...@@ -656,13 +656,8 @@ static int write_skip_frames(AVFormatContext *s, int stream_index, int64_t dts) ...@@ -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) static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
unsigned char tag[5];
const int stream_index = pkt->stream_index; const int stream_index = pkt->stream_index;
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[stream_index]->codec; 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; int ret;
if (enc->codec_id == AV_CODEC_ID_H264 && enc->codec_tag == MKTAG('H','2','6','4') && pkt->size) { 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) ...@@ -678,6 +673,9 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
return avi_write_packet_internal(s, pkt); /* Passthrough */ return avi_write_packet_internal(s, pkt); /* Passthrough */
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { 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) { 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; int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
int expected_stride = ((enc->width * bpc + 31) >> 5)*4; int expected_stride = ((enc->width * bpc + 31) >> 5)*4;
...@@ -686,11 +684,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -686,11 +684,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
return ret; return ret;
} else } else
ret = 0; ret = 0;
if (pix_fmt == AV_PIX_FMT_NONE && enc->bits_per_coded_sample == 1) if (enc->pix_fmt == AV_PIX_FMT_PAL8) {
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) {
int ret2 = ff_get_packet_palette(s, opkt, ret, avist->palette); int ret2 = ff_get_packet_palette(s, opkt, ret, avist->palette);
if (ret2 < 0) if (ret2 < 0)
return ret2; return ret2;
...@@ -712,6 +706,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -712,6 +706,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
avist->pal_offset = 0; avist->pal_offset = 0;
} }
if (memcmp(avist->palette, avist->old_palette, pal_size * 4)) { if (memcmp(avist->palette, avist->old_palette, pal_size * 4)) {
unsigned char tag[5];
avi_stream2fourcc(tag, stream_index, enc->codec_type); avi_stream2fourcc(tag, stream_index, enc->codec_type);
tag[2] = 'p'; tag[3] = 'c'; tag[2] = 'p'; tag[3] = 'c';
pc_tag = ff_start_tag(pb, tag); pc_tag = ff_start_tag(pb, tag);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment