mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-24 02:09:03 +03:00
avcodec/decode: discard the padding when it overlaps the skipped samples
AV_PKT_DATA_SKIP_SAMPLES gives the samples to skip at the start of a frame and the padding to discard at its end. When both apply to the same frame and overlap, the padding was compared with what was left after the skip, found too large, and ignored, so the padding was output. Check the padding against the whole frame, then discard what is left of it after the skip. The overlapping case of the api-skip-samples test now outputs nothing instead of the padding.
This commit is contained in:
committed by
Romain Beauxis
parent
843e83ed2d
commit
9dbc65bd60
@@ -324,6 +324,7 @@ static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *disca
|
||||
AVCodecInternal *avci = avctx->internal;
|
||||
AVFrameSideData *side;
|
||||
uint32_t discard_padding = 0;
|
||||
int nb_samples = frame->nb_samples;
|
||||
uint8_t skip_reason = 0;
|
||||
uint8_t discard_reason = 0;
|
||||
|
||||
@@ -399,7 +400,9 @@ static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *disca
|
||||
}
|
||||
}
|
||||
|
||||
if (discard_padding > 0 && discard_padding <= frame->nb_samples) {
|
||||
if (discard_padding > 0 && discard_padding <= nb_samples) {
|
||||
// The padding may overlap the samples skipped at the start.
|
||||
discard_padding = FFMIN(discard_padding, frame->nb_samples);
|
||||
if (discard_padding == frame->nb_samples) {
|
||||
av_log(avctx, AV_LOG_DEBUG, "discard whole frame\n");
|
||||
*discarded_samples += frame->nb_samples;
|
||||
|
||||
@@ -3,5 +3,5 @@ frame 1000 skip 300 discard 0: 700 samples
|
||||
frame 1000 skip 0 discard 400: 600 samples
|
||||
frame 1000 skip 300 discard 400: 300 samples
|
||||
frame 1000 skip 300 discard 700: 0 samples
|
||||
frame 1000 skip 300 discard 800: 700 samples
|
||||
frame 1000 skip 300 discard 800: 0 samples
|
||||
frame 1000 skip 300 discard 1100: 700 samples
|
||||
|
||||
Reference in New Issue
Block a user