mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
avcodec: set skip_samples in generic code
Decoders should only worry about exporting AVCodeContext->delay during init. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@@ -354,6 +354,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
||||
if (!avctx->bit_rate)
|
||||
avctx->bit_rate = get_bit_rate(avctx);
|
||||
|
||||
avci->skip_samples = avctx->delay;
|
||||
|
||||
/* validate channel layout from the decoder */
|
||||
if ((avctx->ch_layout.nb_channels && !av_channel_layout_check(&avctx->ch_layout)) ||
|
||||
avctx->ch_layout.nb_channels > FF_SANE_NB_CHANNELS) {
|
||||
|
||||
@@ -87,7 +87,6 @@ static av_cold int liblc3_decode_init(AVCodecContext *avctx)
|
||||
|
||||
avctx->delay = lc3_hr_delay_samples(
|
||||
liblc3->hr_mode, liblc3->frame_us, liblc3->srate_hz);
|
||||
avctx->internal->skip_samples = avctx->delay;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ static av_cold int libopus_decode_init(AVCodecContext *avc)
|
||||
#endif
|
||||
|
||||
/* Decoder delay (in samples) at 48kHz */
|
||||
avc->delay = avc->internal->skip_samples = opus->pre_skip;
|
||||
avc->delay = opus->pre_skip;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -321,8 +321,6 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
avctx->delay = AV_RL16(extradata + 10);
|
||||
if (avctx->internal)
|
||||
avctx->internal->skip_samples = avctx->delay;
|
||||
|
||||
channels = avctx->extradata ? extradata[9] : (channels == 1) ? 1 : 2;
|
||||
if (!channels) {
|
||||
|
||||
@@ -140,7 +140,7 @@ static av_cold int wma_decode_init(AVCodecContext *avctx)
|
||||
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
|
||||
|
||||
avctx->internal->skip_samples = s->frame_len * 2;
|
||||
avctx->delay = s->frame_len * 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user