aacdec: do not mutate input packet metadata

Apparently the demuxer outputs the wrong padding for HE-AAC (based on
the raw sample rate, or so). aacdec contains a hack to adjust the muxer
padding accordingly before it's used to trim the decoder output. This
modified the packet side data, which in combination with the old
decoding API would change the packet the user passed to the decoder.
This is clearly not allowed, and it breaks running some gapless fate
tests with "-fflags +keepside" applied (without keepside, the packet
metadata is typically newly allocated, essentially making a copy and not
modifying the user's input packet).

This should probably be fixed in the demuxer (and consequently also the
muxer), but for now only fix the immediate problem.

Regression since 946ed78f5f (2012).
pull/230/merge
wm4 8 years ago
parent 53a5cea478
commit fcfc78cbab
  1. 8
      libavcodec/aacdec_template.c
  2. 2
      libavcodec/internal.h
  3. 4
      libavcodec/utils.c

@ -3095,12 +3095,8 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
ac->oc[1].status = OC_LOCKED; ac->oc[1].status = OC_LOCKED;
} }
if (multiplier) { if (multiplier)
int side_size; avctx->internal->skip_samples_multiplier = 2;
const uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
if (side && side_size>=4)
AV_WL32(side, 2*AV_RL32(side));
}
if (!ac->frame->data[0] && samples) { if (!ac->frame->data[0] && samples) {
av_log(avctx, AV_LOG_ERROR, "no frame data found\n"); av_log(avctx, AV_LOG_ERROR, "no frame data found\n");

@ -174,6 +174,8 @@ typedef struct AVCodecInternal {
AVFrame *buffer_frame; AVFrame *buffer_frame;
int draining_done; int draining_done;
int showed_multi_packet_warning; int showed_multi_packet_warning;
int skip_samples_multiplier;
} AVCodecInternal; } AVCodecInternal;
struct AVCodecDefault { struct AVCodecDefault {

@ -1305,6 +1305,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
goto free_and_end; goto free_and_end;
} }
avctx->internal->skip_samples_multiplier = 1;
if (codec->priv_data_size > 0) { if (codec->priv_data_size > 0) {
if (!avctx->priv_data) { if (!avctx->priv_data) {
avctx->priv_data = av_mallocz(codec->priv_data_size); avctx->priv_data = av_mallocz(codec->priv_data_size);
@ -2387,7 +2389,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
side= av_packet_get_side_data(avctx->internal->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); side= av_packet_get_side_data(avctx->internal->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
if(side && side_size>=10) { if(side && side_size>=10) {
avctx->internal->skip_samples = AV_RL32(side); avctx->internal->skip_samples = AV_RL32(side) * avctx->internal->skip_samples_multiplier;
discard_padding = AV_RL32(side + 4); discard_padding = AV_RL32(side + 4);
av_log(avctx, AV_LOG_DEBUG, "skip %d / discard %d samples due to side data\n", av_log(avctx, AV_LOG_DEBUG, "skip %d / discard %d samples due to side data\n",
avctx->internal->skip_samples, (int)discard_padding); avctx->internal->skip_samples, (int)discard_padding);

Loading…
Cancel
Save