diff options
author | Anton Khirnov <anton@khirnov.net> | 2016-07-01 06:53:18 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-07-02 09:30:40 +0200 |
commit | b55566db4c51d920a6496455bb30a608e5a50a41 (patch) | |
tree | 60c05e924adfb1e7ccb92dbec8d743d08821f74b | |
parent | be3e807c8fad1f82766c083073e44396799f155b (diff) | |
download | ffmpeg-streaming-b55566db4c51d920a6496455bb30a608e5a50a41.zip ffmpeg-streaming-b55566db4c51d920a6496455bb30a608e5a50a41.tar.gz |
avconv: use avcodec_parameters_copy() with streamcopy
This preserves all the information in the codec parameters.
The wavpack ref changes are caused by the fact that now the sample
format is set, so matroskaenc can use it to set the bit depth.
Bug-Id: 945, along with the previous commit
-rw-r--r-- | avconv.c | 64 | ||||
-rw-r--r-- | tests/fate/wavpack.mak | 4 |
2 files changed, 14 insertions, 54 deletions
@@ -1812,39 +1812,23 @@ static int init_output_stream_streamcopy(OutputStream *ost) AVCodecParameters *par_dst = ost->st->codecpar; AVCodecParameters *par_src = ist->st->codecpar; AVRational sar; - int i; - uint64_t extra_size; - - extra_size = (uint64_t)par_src->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE; - if (extra_size > INT_MAX) { - return AVERROR(EINVAL); - } - - ost->st->disposition = ist->st->disposition; - - /* if stream_copy is selected, no need to decode or encode */ - par_dst->codec_id = par_src->codec_id; - par_dst->codec_type = par_src->codec_type; + uint32_t codec_tag = par_dst->codec_tag; + int i, ret; - if (!par_dst->codec_tag) { + if (!codec_tag) { if (!of->ctx->oformat->codec_tag || - av_codec_get_id (of->ctx->oformat->codec_tag, par_src->codec_tag) == par_dst->codec_id || + av_codec_get_id (of->ctx->oformat->codec_tag, par_src->codec_tag) == par_src->codec_id || av_codec_get_tag(of->ctx->oformat->codec_tag, par_src->codec_id) <= 0) - par_dst->codec_tag = par_src->codec_tag; + codec_tag = par_src->codec_tag; } - par_dst->bit_rate = par_src->bit_rate; - par_dst->field_order = par_src->field_order; - par_dst->chroma_location = par_src->chroma_location; + ret = avcodec_parameters_copy(par_dst, par_src); + if (ret < 0) + return ret; - if (par_src->extradata) { - par_dst->extradata = av_mallocz(extra_size); - if (!par_dst->extradata) { - return AVERROR(ENOMEM); - } - memcpy(par_dst->extradata, par_src->extradata, par_src->extradata_size); - par_dst->extradata_size = par_src->extradata_size; - } + par_dst->codec_tag = codec_tag; + + ost->st->disposition = ist->st->disposition; ost->st->time_base = ist->st->time_base; @@ -1873,21 +1857,7 @@ static int init_output_stream_streamcopy(OutputStream *ost) if (!ost->parser_avctx) return AVERROR(ENOMEM); - switch (par_dst->codec_type) { - case AVMEDIA_TYPE_AUDIO: - if (audio_volume != 256) { - av_log(NULL, AV_LOG_FATAL, "-acodec copy and -vol are incompatible (frames are not decoded)\n"); - exit_program(1); - } - par_dst->channel_layout = par_src->channel_layout; - par_dst->sample_rate = par_src->sample_rate; - par_dst->channels = par_src->channels; - par_dst->block_align = par_src->block_align; - break; - case AVMEDIA_TYPE_VIDEO: - par_dst->format = par_src->format; - par_dst->width = par_src->width; - par_dst->height = par_src->height; + if (par_dst->codec_type == AVMEDIA_TYPE_VIDEO) { if (ost->frame_aspect_ratio) sar = av_d2q(ost->frame_aspect_ratio * par_dst->height / par_dst->width, 255); else if (ist->st->sample_aspect_ratio.num) @@ -1895,16 +1865,6 @@ static int init_output_stream_streamcopy(OutputStream *ost) else sar = par_src->sample_aspect_ratio; ost->st->sample_aspect_ratio = par_dst->sample_aspect_ratio = sar; - break; - case AVMEDIA_TYPE_SUBTITLE: - par_dst->width = par_src->width; - par_dst->height = par_src->height; - break; - case AVMEDIA_TYPE_DATA: - case AVMEDIA_TYPE_ATTACHMENT: - break; - default: - abort(); } return 0; diff --git a/tests/fate/wavpack.mak b/tests/fate/wavpack.mak index 92a9c1d..05538f0 100644 --- a/tests/fate/wavpack.mak +++ b/tests/fate/wavpack.mak @@ -91,12 +91,12 @@ fate-wavpack-matroskamode: CMD = md5 -i $(TARGET_SAMPLES)/wavpack/special/matros FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-mono fate-wavpack-matroska_mux-mono: CMD = md5 -i $(TARGET_SAMPLES)/wavpack/num_channels/mono_16bit_int.wv -c copy -fflags +bitexact -f matroska fate-wavpack-matroska_mux-mono: CMP = oneline -fate-wavpack-matroska_mux-mono: REF = 90bb202ca75333d25146c52f863f93bd +fate-wavpack-matroska_mux-mono: REF = f87d2356f34e1ac0d6a873fac8bc0453 FATE_WAVPACK-$(call DEMMUX, WV, MATROSKA) += fate-wavpack-matroska_mux-61 fate-wavpack-matroska_mux-61: CMD = md5 -i $(TARGET_SAMPLES)/wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv -c copy -fflags +bitexact -f matroska fate-wavpack-matroska_mux-61: CMP = oneline -fate-wavpack-matroska_mux-61: REF = de9f9f8136377af41ac1e899aaec6752 +fate-wavpack-matroska_mux-61: REF = 6926fde4cb74ec63a5f21a26bec62688 FATE_SAMPLES_AVCONV += $(FATE_WAVPACK-yes) fate-wavpack: $(FATE_WAVPACK-yes) |