1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00

avcodec/encode: propagate skip samples side data if present

Only for non-delay codecs.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2026-05-07 15:15:47 -03:00
parent 355d05a784
commit 53d46a51fa
32 changed files with 51 additions and 37 deletions

View File

@@ -275,6 +275,20 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt,
avpkt->duration = ff_samples_to_time_base(avctx,
frame->nb_samples);
}
if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES);
if (sd && sd->size >= 10) {
uint8_t *skip_samples = av_packet_new_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
if (!skip_samples) {
ret = AVERROR(ENOMEM);
goto unref;
}
AV_WL32A(skip_samples + 0, AV_RL32(sd->data + 0));
AV_WL32A(skip_samples + 4, AV_RL32(sd->data + 4));
AV_WB8 (skip_samples + 8, AV_RB8 (sd->data + 8));
AV_WB8 (skip_samples + 9, AV_RB8 (sd->data + 9));
}
}
}
ret = ff_encode_reordered_opaque(avctx, avpkt, frame);

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s16le
#sample_rate 0: 192000
#channel_layout_name 0: 5.1(side)
0, -4096, -4096, 2048, 24576, 0x00000000
0, -4096, -4096, 2048, 24576, 0x00000000, S=1, Skip Samples, 10, 0x00900010
0, -2048, -2048, 2048, 24576, 0x00000000
0, 0, 0, 2048, 24576, 0x004b62f1
0, 2048, 2048, 2048, 24576, 0x66edba5f

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s16le
#sample_rate 0: 192000
#channel_layout_name 0: 5.1(side)
0, -4096, -4096, 2048, 24576, 0x00000000
0, -4096, -4096, 2048, 24576, 0x00000000, S=1, Skip Samples, 10, 0x00900010
0, -2048, -2048, 2048, 24576, 0x00000000
0, 0, 0, 2048, 24576, 0x004b62f1
0, 2048, 2048, 2048, 24576, 0x66edba5f

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s16le
#sample_rate 0: 192000
#channel_layout_name 0: 5.1(side)
0, -4096, -4096, 2048, 24576, 0x00000000
0, -4096, -4096, 2048, 24576, 0x00000000, S=1, Skip Samples, 10, 0x00900010
0, -2048, -2048, 2048, 24576, 0x00000000
0, 0, 0, 2048, 24576, 0x004b62f1
0, 2048, 2048, 2048, 24576, 0x66edba5f

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s16le
#sample_rate 0: 192000
#channel_layout_name 0: 5.1(side)
0, -4096, -4096, 2048, 24576, 0x00000000
0, -4096, -4096, 2048, 24576, 0x00000000, S=1, Skip Samples, 10, 0x00900010
0, -2048, -2048, 2048, 24576, 0x00000000
0, 0, 0, 2048, 24576, 0x004b62f1
0, 2048, 2048, 2048, 24576, 0x66edba5f

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s16le
#sample_rate 0: 192000
#channel_layout_name 0: stereo
0, -4096, -4096, 2048, 8192, 0x00000000
0, -4096, -4096, 2048, 8192, 0x00000000, S=1, Skip Samples, 10, 0x00900010
0, -2048, -2048, 2048, 8192, 0x5a180402
0, 0, 0, 2048, 8192, 0x53413568
0, 2048, 2048, 2048, 8192, 0x2a34e9e1

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s16le
#sample_rate 0: 192000
#channel_layout_name 0: 5.1(side)
0, -4096, -4096, 2048, 24576, 0x00000000
0, -4096, -4096, 2048, 24576, 0x00000000, S=1, Skip Samples, 10, 0x00900010
0, -2048, -2048, 2048, 24576, 0x00000000
0, 0, 0, 2048, 24576, 0x004b62f1
0, 2048, 2048, 2048, 24576, 0x66edba5f

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 5.1(side)
0, -1024, -1024, 512, 9216, 0x00000000
0, -1024, -1024, 512, 9216, 0x00000000, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 9216, 0x00000000
0, 0, 0, 512, 9216, 0x03de31ea
0, 512, 512, 512, 9216, 0xfdbede52

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: stereo
0, -1024, -1024, 512, 3072, 0x00000000
0, -1024, -1024, 512, 3072, 0x00000000, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 3072, 0x00000000
0, 0, 0, 512, 3072, 0xa27d155c
0, 512, 512, 512, 3072, 0x56efed53

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 5.1(side)
0, -1024, -1024, 512, 9216, 0x00000000
0, -1024, -1024, 512, 9216, 0x00000000, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 9216, 0x00000000
0, 0, 0, 512, 9216, 0x03de31ea
0, 512, 512, 512, 9216, 0xfdbede52

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 5.1(side)
0, -1024, -1024, 1024, 18432, 0x00000000
0, -1024, -1024, 1024, 18432, 0x00000000, S=1, Skip Samples, 10, 0x00240004
0, 0, 0, 1024, 18432, 0x5ca6ebf7
0, 1024, 1024, 1024, 18432, 0xb5520ea3
[PACKET]

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 5.1(side)
0, -1024, -1024, 1024, 18432, 0x00000000
0, -1024, -1024, 1024, 18432, 0x00000000, S=1, Skip Samples, 10, 0x00240004
0, 0, 0, 1024, 18432, 0x5ca6ebf7
0, 1024, 1024, 1024, 18432, 0xb5520ea3
[PACKET]

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 5.1(side)
0, -1024, -1024, 1024, 18432, 0x00000000
0, -1024, -1024, 1024, 18432, 0x00000000, S=1, Skip Samples, 10, 0x00240004
0, 0, 0, 1024, 18432, 0x5ca6ebf7
0, 1024, 1024, 1024, 18432, 0xb5520ea3
[PACKET]

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 7.1
0, -1024, -1024, 512, 12288, 0xa5edf1df
0, -1024, -1024, 512, 12288, 0xa5edf1df, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 12288, 0x00000000
0, 0, 0, 512, 12288, 0x6613373c
0, 512, 512, 512, 12288, 0xa36ccec0

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 5.1(side)
0, -1024, -1024, 512, 9216, 0xa1d1f1df
0, -1024, -1024, 512, 9216, 0xa1d1f1df, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 9216, 0x00000000
0, 0, 0, 512, 9216, 0xeeb20c83
0, 512, 512, 512, 9216, 0xfda4b141

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 5.1(side)
0, -1024, -1024, 512, 9216, 0xa1d1f1df
0, -1024, -1024, 512, 9216, 0xa1d1f1df, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 9216, 0x00000000
0, 0, 0, 512, 9216, 0xeeb20c83
0, 512, 512, 512, 9216, 0xfda4b141

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 7.1
0, -1024, -1024, 512, 12288, 0xa5edf1df
0, -1024, -1024, 512, 12288, 0xa5edf1df, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 12288, 0x00000000
0, 0, 0, 512, 12288, 0x6613373c
0, 512, 512, 512, 12288, 0xa36ccec0

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: stereo
0, -1024, -1024, 512, 3072, 0x00000000
0, -1024, -1024, 512, 3072, 0x00000000, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 3072, 0x00000000
0, 0, 0, 512, 3072, 0x1bf4e1f9
0, 512, 512, 512, 3072, 0x89a1d6cd

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 5.1(side)
0, -1024, -1024, 512, 9216, 0xa1d1f1df
0, -1024, -1024, 512, 9216, 0xa1d1f1df, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 9216, 0x00000000
0, 0, 0, 512, 9216, 0xd12a04fd
0, 512, 512, 512, 9216, 0x7832be51

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 96000
#channel_layout_name 0: 7.1
0, -2048, -2048, 1024, 24576, 0xbdfff0e4
0, -2048, -2048, 1024, 24576, 0xbdfff0e4, S=1, Skip Samples, 10, 0x00480008
0, -1024, -1024, 1024, 24576, 0x00000000
0, 0, 0, 1024, 24576, 0x47d8aee7
0, 1024, 1024, 1024, 24576, 0x2018104b

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 96000
#channel_layout_name 0: 5.1(side)
0, -2048, -2048, 1024, 18432, 0xb8cdf0e4
0, -2048, -2048, 1024, 18432, 0xb8cdf0e4, S=1, Skip Samples, 10, 0x00480008
0, -1024, -1024, 1024, 18432, 0x00000000
0, 0, 0, 1024, 18432, 0x89262806
0, 1024, 1024, 1024, 18432, 0xab935a48

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 96000
#channel_layout_name 0: 5.1(side)
0, -2048, -2048, 1024, 18432, 0xb8cdf0e4
0, -2048, -2048, 1024, 18432, 0xb8cdf0e4, S=1, Skip Samples, 10, 0x00480008
0, -1024, -1024, 1024, 18432, 0x00000000
0, 0, 0, 1024, 18432, 0x89262806
0, 1024, 1024, 1024, 18432, 0xab935a48

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 96000
#channel_layout_name 0: 5.1(side)
0, -2048, -2048, 1024, 18432, 0x00000000
0, -2048, -2048, 1024, 18432, 0x00000000, S=1, Skip Samples, 10, 0x00480008
0, -1024, -1024, 1024, 18432, 0x00000000
0, 0, 0, 1024, 18432, 0xa6b18739
0, 1024, 1024, 1024, 18432, 0xd4df050d

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 96000
#channel_layout_name 0: 5.1(side)
0, -2048, -2048, 1024, 18432, 0x00000000
0, -2048, -2048, 1024, 18432, 0x00000000, S=1, Skip Samples, 10, 0x00480008
0, -1024, -1024, 1024, 18432, 0x00000000
0, 0, 0, 1024, 18432, 0xa6b18739
0, 1024, 1024, 1024, 18432, 0xd4df050d

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 96000
#channel_layout_name 0: 5.1(side)
0, -2048, -2048, 1024, 18432, 0x00000000
0, -2048, -2048, 1024, 18432, 0x00000000, S=1, Skip Samples, 10, 0x00480008
0, -1024, -1024, 1024, 18432, 0x00000000
0, 0, 0, 1024, 18432, 0xa6b18739
0, 1024, 1024, 1024, 18432, 0xd4df050d

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 6.1
0, -1024, -1024, 512, 10752, 0xd4320448
0, -1024, -1024, 512, 10752, 0xd4320448, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 10752, 0x00000000
0, 0, 0, 512, 10752, 0xb0d63493
0, 512, 512, 512, 10752, 0xb25bd689

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 5.1(side)
0, -1024, -1024, 512, 9216, 0xb1820448
0, -1024, -1024, 512, 9216, 0xb1820448, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 9216, 0x00000000
0, 0, 0, 512, 9216, 0xeeef4c10
0, 512, 512, 512, 9216, 0x7bb4ed68

View File

@@ -3,7 +3,7 @@
#codec_id 0: pcm_s24le
#sample_rate 0: 48000
#channel_layout_name 0: 5.1(side)
0, -1024, -1024, 512, 9216, 0xb1820448
0, -1024, -1024, 512, 9216, 0xb1820448, S=1, Skip Samples, 10, 0x00240004
0, -512, -512, 512, 9216, 0x00000000
0, 0, 0, 512, 9216, 0xeeef4c10
0, 512, 512, 512, 9216, 0x7bb4ed68

View File

@@ -6,4 +6,4 @@
0, -256, -256, 1536, 416, 0x3001fb2d
0, 1280, 1280, 1536, 418, 0xba72fc16
0, 2816, 2816, 1536, 418, 0xba72fc16
0, 4352, 4352, 3, 418, 0xba72fc16
0, 4352, 4352, 3, 418, 0xba72fc16, S=1, Skip Samples, 10, 0x06070102

View File

@@ -1,5 +1,5 @@
ece637ed28526724c88f5c69b8bf7d6f *tests/data/fate/matroska-encoding-delay.matroska
961252 tests/data/fate/matroska-encoding-delay.matroska
5febd4af0b197d8d0756fcaa99c066a2 *tests/data/fate/matroska-encoding-delay.matroska
961258 tests/data/fate/matroska-encoding-delay.matroska
#extradata 0: 22, 0x32ea0490
#tb 0: 1/1000
#media_type 0: video
@@ -21,7 +21,7 @@ ece637ed28526724c88f5c69b8bf7d6f *tests/data/fate/matroska-encoding-delay.matros
1, 86, 86, 24, 1152, 0xc9e85398
1, 110, 110, 24, 1152, 0xda1287d3
0, 120, 120, 40, 238290, 0xbe18b18f
1, 134, 134, 16, 1152, 0x1c9a6102
1, 134, 134, 16, 1152, 0x1c9a6102, S=1, Skip Samples, 10, 0x03050081
[PACKET]
codec_type=audio
stream_index=1

View File

@@ -1,3 +1,3 @@
dd709c2b5e173eaca39cdd4a10aac3ec *tests/data/lavf/lavf.mkv
320447 tests/data/lavf/lavf.mkv
tests/data/lavf/lavf.mkv CRC=0x29d44368
3d79de7fc1c67016e864b40cdb207ff7 *tests/data/lavf/lavf.mkv
320454 tests/data/lavf/lavf.mkv
tests/data/lavf/lavf.mkv CRC=0xb05f51a3

View File

@@ -1,3 +1,3 @@
7cd7b06892b74d66da217c8dda90bfac *tests/data/lavf/lavf.mkv_attachment
472597 tests/data/lavf/lavf.mkv_attachment
tests/data/lavf/lavf.mkv_attachment CRC=0x29d44368
2d9ed072357227c31cb68534f7483a81 *tests/data/lavf/lavf.mkv_attachment
472604 tests/data/lavf/lavf.mkv_attachment
tests/data/lavf/lavf.mkv_attachment CRC=0xb05f51a3