avformat/apngenc: use the stream parameters extradata if available

Fixes remuxing apng streams coming from the apng demuxer, which sends extradata
during init.

Signed-off-by: James Almer <jamrial@gmail.com>
pull/241/head
James Almer 8 years ago
parent 16c429166d
commit 50e0e96f3f
  1. 9
      libavformat/apngenc.c
  2. 6
      tests/lavf-regression.sh
  3. 3
      tests/ref/lavf/apng

@ -81,6 +81,7 @@ static void apng_write_chunk(AVIOContext *io_context, uint32_t tag,
static int apng_write_header(AVFormatContext *format_context)
{
APNGMuxContext *apng = format_context->priv_data;
AVCodecParameters *par = format_context->streams[0]->codecpar;
if (format_context->nb_streams != 1 ||
format_context->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
@ -101,6 +102,14 @@ static int apng_write_header(AVFormatContext *format_context)
avio_wb64(format_context->pb, PNGSIG);
// Remaining headers are written when they are copied from the encoder
if (par->extradata_size) {
apng->extra_data = av_mallocz(par->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!apng->extra_data)
return AVERROR(ENOMEM);
apng->extra_data_size = par->extradata_size;
memcpy(apng->extra_data, par->extradata, par->extradata_size);
}
return 0;
}

@ -216,9 +216,9 @@ if [ -n "$do_apng" ] ; then
file=${outfile}lavf.apng
do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t 1 -pix_fmt rgb24
do_avconv_crc $file $DEC_OPTS -i $target_path/$file -pix_fmt rgb24
#file_copy=${outfile}lavf.copy.apng
#do_avconv $file_copy $DEC_OPTS -i $file $ENC_OPTS -c copy
#do_avconv_crc $file_copy $DEC_OPTS -i $target_path/$file_copy
file_copy=${outfile}lavf.copy.apng
do_avconv $file_copy $DEC_OPTS -i $file $ENC_OPTS -c copy
do_avconv_crc $file_copy $DEC_OPTS -i $target_path/$file_copy
file=${outfile}lavf.png
do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -pix_fmt rgb24 -frames:v 1 -f apng
do_avconv_crc $file $DEC_OPTS -i $target_path/$file -pix_fmt rgb24

@ -1,6 +1,9 @@
a4c46fad7716ad094eb3c78b74ca0244 *./tests/data/lavf/lavf.apng
6209864 ./tests/data/lavf/lavf.apng
./tests/data/lavf/lavf.apng CRC=0x87b3c15f
a4c46fad7716ad094eb3c78b74ca0244 *./tests/data/lavf/lavf.copy.apng
6209864 ./tests/data/lavf/lavf.copy.apng
./tests/data/lavf/lavf.copy.apng CRC=0x87b3c15f
c5900fdd1b2fc30b985793f5226fd0c4 *./tests/data/lavf/lavf.png
248854 ./tests/data/lavf/lavf.png
./tests/data/lavf/lavf.png CRC=0xd8c7b7a1

Loading…
Cancel
Save