PR #21161 opened by Marton Balint (cus) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21161 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21161.patch
The format does not contain audio timestamps and the calculated audio pts values were only correct for compressed audio. It is better to remove PTS calculation entirely and let the generic code handle it. Fixes ticket #8595. Fixes #20983. Fate test changes are because of the different audio time base which is now always 1/sample_rate. Signed-off-by: Marton Balint <[email protected]> >From 564a5ab027ad2b852d0593d18a772b2e8ec00ad7 Mon Sep 17 00:00:00 2001 From: Marton Balint <[email protected]> Date: Thu, 11 Dec 2025 00:39:19 +0100 Subject: [PATCH] avformat/xmv: do not set audio pts values The format does not contain audio timestamps and the calculated audio pts values were only correct for compressed audio. It is better to remove PTS calculation entirely and let the generic code handle it. Fixes ticket #8595. Fixes #20983. Fate test changes are because of the different audio time base which is now always 1/sample_rate. Signed-off-by: Marton Balint <[email protected]> --- libavformat/xmv.c | 18 +--- tests/ref/fate/xmv-demux | 184 +++++++++++++++++++-------------------- 2 files changed, 93 insertions(+), 109 deletions(-) diff --git a/libavformat/xmv.c b/libavformat/xmv.c index 2c5e2bb475..57b229b1ee 100644 --- a/libavformat/xmv.c +++ b/libavformat/xmv.c @@ -85,7 +85,6 @@ typedef struct XMVAudioPacket { uint64_t bit_rate; ///< Bits of compressed data per second. uint16_t flags; ///< Flags unsigned block_align; ///< Bytes per compressed block. - uint16_t block_samples; ///< Decompressed samples per compressed block. enum AVCodecID codec_id; ///< The codec ID of the compression scheme. @@ -93,8 +92,6 @@ typedef struct XMVAudioPacket { uint64_t data_offset; ///< The offset of the audio data within the file. uint32_t frame_size; ///< Number of bytes to put into an audio frame. - - uint64_t block_count; ///< Running counter of decompressed audio block. } XMVAudioPacket; /** Context for demuxing an XMV file. */ @@ -195,14 +192,12 @@ static int xmv_read_header(AVFormatContext *s) packet->sample_rate * packet->channels; packet->block_align = XMV_BLOCK_ALIGN_SIZE * packet->channels; - packet->block_samples = 64; packet->codec_id = ff_wav_codec_get_id(packet->compression, packet->bits_per_sample); packet->stream_index = -1; packet->frame_size = 0; - packet->block_count = 0; /* TODO: ADPCM'd 5.1 sound is encoded in three separate streams. * Those need to be interleaved to a proper 5.1 stream. */ @@ -343,7 +338,7 @@ static int xmv_process_packet_header(AVFormatContext *s) ast->codecpar->bit_rate = packet->bit_rate; ast->codecpar->block_align = 36 * packet->channels; - avpriv_set_pts_info(ast, 32, packet->block_samples, packet->sample_rate); + avpriv_set_pts_info(ast, 32, 1, packet->sample_rate); packet->stream_index = ast->index; @@ -444,7 +439,6 @@ static int xmv_fetch_audio_packet(AVFormatContext *s, XMVAudioPacket *audio = &xmv->audio[stream]; uint32_t data_size; - uint32_t block_count; int result; /* Seek to it */ @@ -465,16 +459,6 @@ static int xmv_fetch_audio_packet(AVFormatContext *s, pkt->stream_index = audio->stream_index; - /* Calculate the PTS */ - - block_count = data_size / audio->block_align; - - pkt->duration = block_count; - pkt->pts = audio->block_count; - pkt->dts = AV_NOPTS_VALUE; - - audio->block_count += block_count; - /* Advance offset */ audio->data_size -= data_size; audio->data_offset += data_size; diff --git a/tests/ref/fate/xmv-demux b/tests/ref/fate/xmv-demux index 603b958b73..0349f5c997 100644 --- a/tests/ref/fate/xmv-demux +++ b/tests/ref/fate/xmv-demux @@ -4,189 +4,189 @@ #codec_id 0: wmv2 #dimensions 0: 640x480 #sar 0: 0/1 -#tb 1: 16/11025 +#tb 1: 1/44100 #media_type 1: audio #codec_id 1: adpcm_ima_xbox #sample_rate 1: 44100 #channel_layout_name 1: stereo 0, 0, 0, 0, 1508, 0xefceba48 -1, 0, 0, 83, 5976, 0xfa2c2db9 -1, 83, 83, 83, 5976, 0x256b935c -1, 166, 166, 83, 5976, 0xa78a9563 -1, 249, 249, 83, 5976, 0x4ea056f4 -1, 332, 332, 83, 5976, 0xda772d8d -1, 415, 415, 83, 5976, 0xafacf7c9 +1, 0, 0, 5312, 5976, 0xfa2c2db9 +1, 5312, 5312, 5312, 5976, 0x256b935c +1, 10624, 10624, 5312, 5976, 0xa78a9563 +1, 15936, 15936, 5312, 5976, 0x4ea056f4 +1, 21248, 21248, 5312, 5976, 0xda772d8d +1, 26560, 26560, 5312, 5976, 0xafacf7c9 0, 640, 640, 0, 108, 0x06713c96, F=0x0 0, 680, 680, 0, 952, 0xd306df7e, F=0x0 0, 720, 720, 0, 2312, 0xaf316585, F=0x0 -1, 498, 498, 83, 5976, 0xdeb003f4 +1, 31872, 31872, 5312, 5976, 0xdeb003f4 0, 760, 760, 0, 3872, 0xfc1c527c, F=0x0 0, 800, 800, 0, 20, 0xaffc0edd, F=0x0 0, 840, 840, 0, 6600, 0xe1b66c7f, F=0x0 -1, 581, 581, 28, 2016, 0xa7380d36 +1, 37184, 37184, 1792, 2016, 0xa7380d36 0, 880, 880, 0, 6868, 0xd5b3f631, F=0x0 -1, 609, 609, 28, 2016, 0xbc090bac +1, 38976, 38976, 1792, 2016, 0xbc090bac 0, 920, 920, 0, 8420, 0xf70ee33b, F=0x0 -1, 637, 637, 28, 2016, 0x6f8c164c +1, 40768, 40768, 1792, 2016, 0x6f8c164c 0, 960, 960, 0, 13144, 0x9a54ef39, F=0x0 -1, 665, 665, 28, 2016, 0x13b80e28 +1, 42560, 42560, 1792, 2016, 0x13b80e28 0, 1000, 1000, 0, 6340, 0xe55bf555, F=0x0 -1, 693, 693, 28, 2016, 0xd40ff863 +1, 44352, 44352, 1792, 2016, 0xd40ff863 0, 1040, 1040, 0, 3736, 0x0b23f89f, F=0x0 -1, 721, 721, 28, 2016, 0x4d530ed7 +1, 46144, 46144, 1792, 2016, 0x4d530ed7 0, 1080, 1080, 0, 2624, 0x79e2e451, F=0x0 -1, 749, 749, 30, 2160, 0x0fbc37eb +1, 47936, 47936, 1920, 2160, 0x0fbc37eb 0, 1120, 1120, 0, 1860, 0x63886f11, F=0x0 -1, 779, 779, 192, 13824, 0x82fb2602 +1, 49856, 49856, 12288, 13824, 0x82fb2602 0, 1160, 1160, 0, 1244, 0x74594601, F=0x0 0, 1200, 1200, 0, 564, 0xf4561dfb, F=0x0 0, 1240, 1240, 0, 80, 0xbf8e2e30, F=0x0 0, 1280, 1280, 0, 20, 0xa0990c29, F=0x0 -1, 971, 971, 192, 13824, 0x08771caf -1, 1163, 1163, 192, 13824, 0xdf7d4a65 -1, 1355, 1355, 193, 13896, 0x24bf3f47 -1, 1548, 1548, 50, 3600, 0x9ad26b9f -1, 1598, 1598, 50, 3600, 0x8c666fd6 -1, 1648, 1648, 50, 3600, 0x305c6ca1 -1, 1698, 1698, 50, 3600, 0x48b04e1e +1, 62144, 62144, 12288, 13824, 0x08771caf +1, 74432, 74432, 12288, 13824, 0xdf7d4a65 +1, 86720, 86720, 12352, 13896, 0x24bf3f47 +1, 99072, 99072, 3200, 3600, 0x9ad26b9f +1, 102272, 102272, 3200, 3600, 0x8c666fd6 +1, 105472, 105472, 3200, 3600, 0x305c6ca1 +1, 108672, 108672, 3200, 3600, 0x48b04e1e 0, 2480, 2480, 0, 104, 0x12413980, F=0x0 0, 2520, 2520, 0, 796, 0x2e698ed3, F=0x0 -1, 1748, 1748, 50, 3600, 0x8c915935 +1, 111872, 111872, 3200, 3600, 0x8c915935 0, 2560, 2560, 0, 1808, 0x8b3e6e5e, F=0x0 0, 2600, 2600, 0, 4712, 0xdbd51737, F=0x0 -1, 1798, 1798, 50, 3600, 0xa8f45e01 +1, 115072, 115072, 3200, 3600, 0xa8f45e01 0, 2640, 2640, 0, 5548, 0xee9c831c, F=0x0 0, 2680, 2680, 0, 6152, 0x9c18ccc1, F=0x0 -1, 1848, 1848, 53, 3816, 0xc64cc5ed +1, 118272, 118272, 3392, 3816, 0xc64cc5ed 0, 2720, 2720, 0, 6452, 0x7860462a, F=0x0 -1, 1901, 1901, 27, 1944, 0x0ac2e3f1 +1, 121664, 121664, 1728, 1944, 0x0ac2e3f1 0, 2760, 2760, 0, 6676, 0xe1b1c9e4, F=0x0 -1, 1928, 1928, 27, 1944, 0x2197dccd +1, 123392, 123392, 1728, 1944, 0x2197dccd 0, 2800, 2800, 0, 10904, 0x0bded7b7, F=0x0 -1, 1955, 1955, 27, 1944, 0x0c02e77f +1, 125120, 125120, 1728, 1944, 0x0c02e77f 0, 2840, 2840, 0, 12844, 0xe6d16cff, F=0x0 -1, 1982, 1982, 27, 1944, 0x675ee06a +1, 126848, 126848, 1728, 1944, 0x675ee06a 0, 2880, 2880, 0, 10920, 0xe114c46b, F=0x0 -1, 2009, 2009, 30, 2160, 0x0d803a8b +1, 128576, 128576, 1920, 2160, 0x0d803a8b 0, 2920, 2920, 0, 5952, 0xb7464634, F=0x0 -1, 2039, 2039, 93, 6696, 0xa7a0dfea +1, 130496, 130496, 5952, 6696, 0xa7a0dfea 0, 2960, 2960, 0, 4732, 0x2fa2e36d, F=0x0 0, 3000, 3000, 0, 2592, 0xf54ddd57, F=0x0 0, 3040, 3040, 0, 1516, 0x4a1cd4d5, F=0x0 0, 3080, 3080, 0, 864, 0x49889afc, F=0x0 -1, 2132, 2132, 93, 6696, 0x59aa3145 +1, 136448, 136448, 5952, 6696, 0x59aa3145 0, 3120, 3120, 0, 468, 0x3932e6a4, F=0x0 0, 3160, 3160, 0, 116, 0x2b8341e6, F=0x0 0, 3200, 3200, 0, 16, 0x6a3109cf, F=0x0 -1, 2225, 2225, 93, 6696, 0x69be4d78 -1, 2318, 2318, 93, 6696, 0x64064c67 -1, 2411, 2411, 93, 6696, 0xc8536f98 -1, 2504, 2504, 93, 6696, 0xc0ce5199 -1, 2597, 2597, 94, 6768, 0x3b275c58 -1, 2691, 2691, 123, 8856, 0x90e5b37c +1, 142400, 142400, 5952, 6696, 0x69be4d78 +1, 148352, 148352, 5952, 6696, 0x64064c67 +1, 154304, 154304, 5952, 6696, 0xc8536f98 +1, 160256, 160256, 5952, 6696, 0xc0ce5199 +1, 166208, 166208, 6016, 6768, 0x3b275c58 +1, 172224, 172224, 7872, 8856, 0x90e5b37c 0, 4000, 4000, 0, 1508, 0xefceba48 -1, 2814, 2814, 123, 8856, 0x86b33366 -1, 2937, 2937, 123, 8856, 0x19e18797 -1, 3060, 3060, 123, 8856, 0x0a0c7fbd -1, 3183, 3183, 124, 8928, 0x4a9b2d42 +1, 180096, 180096, 7872, 8856, 0x86b33366 +1, 187968, 187968, 7872, 8856, 0x19e18797 +1, 195840, 195840, 7872, 8856, 0x0a0c7fbd +1, 203712, 203712, 7936, 8928, 0x4a9b2d42 0, 4640, 4640, 0, 100, 0x45023894, F=0x0 0, 4680, 4680, 0, 948, 0xa65ed345, F=0x0 0, 4720, 4720, 0, 2808, 0xd7285746, F=0x0 0, 4760, 4760, 0, 5372, 0x05794175, F=0x0 -1, 3307, 3307, 21, 1512, 0xed8b3f4b +1, 211648, 211648, 1344, 1512, 0xed8b3f4b 0, 4800, 4800, 0, 11596, 0x8636eca7, F=0x0 -1, 3328, 3328, 21, 1512, 0xa27d3891 +1, 212992, 212992, 1344, 1512, 0xa27d3891 0, 4840, 4840, 0, 11524, 0xe1f39be3, F=0x0 -1, 3349, 3349, 21, 1512, 0xb0f13eb6 +1, 214336, 214336, 1344, 1512, 0xb0f13eb6 0, 4880, 4880, 0, 23392, 0xab053f05, F=0x0 -1, 3370, 3370, 23, 1656, 0xe5a98324 +1, 215680, 215680, 1472, 1656, 0xe5a98324 0, 4920, 4920, 0, 4560, 0x03197d07, F=0x0 -1, 3393, 3393, 31, 2232, 0x15445433 +1, 217152, 217152, 1984, 2232, 0x15445433 0, 4960, 4960, 0, 4440, 0x1cc361a2, F=0x0 -1, 3424, 3424, 31, 2232, 0x5cb348a9 +1, 219136, 219136, 1984, 2232, 0x5cb348a9 0, 5000, 5000, 0, 23688, 0x16030634, F=0x0 -1, 3455, 3455, 31, 2232, 0xf10347da +1, 221120, 221120, 1984, 2232, 0xf10347da 0, 5040, 5040, 0, 16132, 0xf0eca799, F=0x0 -1, 3486, 3486, 34, 2448, 0x3e16a175 +1, 223104, 223104, 2176, 2448, 0x3e16a175 0, 5080, 5080, 0, 29896, 0x0c0988ea, F=0x0 -1, 3520, 3520, 35, 2520, 0x17e3ca2b +1, 225280, 225280, 2240, 2520, 0x17e3ca2b 0, 5120, 5120, 0, 19956, 0x0093aa0b, F=0x0 -1, 3555, 3555, 27, 1944, 0x35c2de84 +1, 227520, 227520, 1728, 1944, 0x35c2de84 0, 5160, 5160, 0, 16392, 0x8829a9ca, F=0x0 -1, 3582, 3582, 27, 1944, 0x55b4db40 +1, 229248, 229248, 1728, 1944, 0x55b4db40 0, 5200, 5200, 0, 16772, 0x9a4a546d, F=0x0 -1, 3609, 3609, 29, 2088, 0xdaae14b2 +1, 230976, 230976, 1856, 2088, 0xdaae14b2 0, 5240, 5240, 0, 8920, 0xcd8ca203, F=0x0 -1, 3638, 3638, 27, 1944, 0x92ccd37f +1, 232832, 232832, 1728, 1944, 0x92ccd37f 0, 5280, 5280, 0, 9632, 0x53c1d37b, F=0x0 -1, 3665, 3665, 27, 1944, 0x70efede1 +1, 234560, 234560, 1728, 1944, 0x70efede1 0, 5320, 5320, 40, 8976, 0xfe4da2cc, F=0x0 -1, 3692, 3692, 27, 1944, 0x7601d304 +1, 236288, 236288, 1728, 1944, 0x7601d304 0, 5360, 5360, 40, 6680, 0x35348fe0, F=0x0 -1, 3719, 3719, 27, 1944, 0x3922ebc2 +1, 238016, 238016, 1728, 1944, 0x3922ebc2 0, 5400, 5400, 40, 9228, 0xcbf62b0c, F=0x0 -1, 3746, 3746, 30, 2160, 0xde462f2e +1, 239744, 239744, 1920, 2160, 0xde462f2e 0, 5440, 5440, 40, 5108, 0xd1d88511, F=0x0 -1, 3776, 3776, 26, 1872, 0x467ac1d2 +1, 241664, 241664, 1664, 1872, 0x467ac1d2 0, 5480, 5480, 40, 10016, 0xaff4b2b2, F=0x0 -1, 3802, 3802, 26, 1872, 0xa1e4cd43 +1, 243328, 243328, 1664, 1872, 0xa1e4cd43 0, 5520, 5520, 40, 7468, 0x23e81ab8, F=0x0 -1, 3828, 3828, 26, 1872, 0x1dceccc6 +1, 244992, 244992, 1664, 1872, 0x1dceccc6 0, 5560, 5560, 40, 4172, 0x253cd05b, F=0x0 -1, 3854, 3854, 26, 1872, 0x2bbad2a5 +1, 246656, 246656, 1664, 1872, 0x2bbad2a5 0, 5600, 5600, 40, 8188, 0x7ede743f, F=0x0 -1, 3880, 3880, 26, 1872, 0xc603d44d +1, 248320, 248320, 1664, 1872, 0xc603d44d 0, 5640, 5640, 40, 2884, 0x2dec55a3, F=0x0 -1, 3906, 3906, 26, 1872, 0x1b4cc261 +1, 249984, 249984, 1664, 1872, 0x1b4cc261 0, 5680, 5680, 40, 3900, 0xd0666a18, F=0x0 -1, 3932, 3932, 26, 1872, 0x10edd6cf +1, 251648, 251648, 1664, 1872, 0x10edd6cf 0, 5720, 5720, 40, 2996, 0x9cc99b8c, F=0x0 -1, 3958, 3958, 33, 2376, 0xecdb9d61 +1, 253312, 253312, 2112, 2376, 0xecdb9d61 0, 5760, 5760, 40, 2156, 0xae612776, F=0x0 -1, 3991, 3991, 36, 2592, 0x5559eced +1, 255424, 255424, 2304, 2592, 0x5559eced 0, 5800, 5800, 40, 3988, 0x0d2c9992, F=0x0 0, 5840, 5840, 40, 1512, 0x6281fc00, F=0x0 -1, 4027, 4027, 36, 2592, 0x8848dfc7 +1, 257728, 257728, 2304, 2592, 0x8848dfc7 0, 5880, 5880, 40, 6544, 0xb75c2562, F=0x0 -1, 4063, 4063, 36, 2592, 0x4ca2d7da +1, 260032, 260032, 2304, 2592, 0x4ca2d7da 0, 5920, 5920, 40, 4108, 0xfb21efc9, F=0x0 -1, 4099, 4099, 36, 2592, 0x285fd7e6 +1, 262336, 262336, 2304, 2592, 0x285fd7e6 0, 5960, 5960, 40, 1096, 0x85922a37, F=0x0 0, 6000, 6000, 40, 9740, 0xe57d7647, F=0x0 -1, 4135, 4135, 36, 2592, 0x2717e404 +1, 264640, 264640, 2304, 2592, 0x2717e404 0, 6040, 6040, 40, 416, 0x61c2ea02, F=0x0 -1, 4171, 4171, 36, 2592, 0xf106111a +1, 266944, 266944, 2304, 2592, 0xf106111a 0, 6080, 6080, 40, 336, 0x1dc5ac1c, F=0x0 -1, 4207, 4207, 36, 2592, 0xd7d01119 +1, 269248, 269248, 2304, 2592, 0xd7d01119 0, 6120, 6120, 40, 204, 0x16f57017, F=0x0 -1, 4243, 4243, 36, 2592, 0x550cfeda +1, 271552, 271552, 2304, 2592, 0x550cfeda 0, 6160, 6160, 40, 112, 0x78374234, F=0x0 0, 6200, 6200, 40, 40, 0x6cb21985, F=0x0 -1, 4279, 4279, 36, 2592, 0x47ad00c4 -1, 4315, 4315, 36, 2592, 0x39bbf306 -1, 4351, 4351, 45, 3240, 0x69addfce -1, 4396, 4396, 297, 21384, 0x254f63e0 -1, 4693, 4693, 298, 21456, 0x2f7a9859 +1, 273856, 273856, 2304, 2592, 0x47ad00c4 +1, 276160, 276160, 2304, 2592, 0x39bbf306 +1, 278464, 278464, 2880, 3240, 0x69addfce +1, 281344, 281344, 19008, 21384, 0x254f63e0 +1, 300352, 300352, 19072, 21456, 0x2f7a9859 0, 6840, 6840, 40, 14420, 0x53324ca4, F=0x0 0, 6880, 6880, 40, 40, 0x10971420, F=0x0 -1, 4991, 4991, 521, 37512, 0x6e962928 -1, 5512, 5512, 38, 2736, 0x1dc91c69 +1, 319424, 319424, 33344, 37512, 0x6e962928 +1, 352768, 352768, 2432, 2736, 0x1dc91c69 0, 8000, 8000, 40, 24904, 0x15574f7e -1, 5550, 5550, 38, 2736, 0x023434fd -1, 5588, 5588, 38, 2736, 0x906f1541 +1, 355200, 355200, 2432, 2736, 0x023434fd +1, 357632, 357632, 2432, 2736, 0x906f1541 0, 8160, 8160, 40, 1908, 0xccb2dd3c, F=0x0 -1, 5626, 5626, 38, 2736, 0x85a31102 +1, 360064, 360064, 2432, 2736, 0x85a31102 0, 8200, 8200, 40, 4676, 0xbfa42b7e, F=0x0 -1, 5664, 5664, 42, 3024, 0x9296a5f3 +1, 362496, 362496, 2688, 3024, 0x9296a5f3 0, 8240, 8240, 40, 3600, 0x87c9dc58, F=0x0 0, 8280, 8280, 40, 8184, 0x504a8e65, F=0x0 -1, 5706, 5706, 27, 1944, 0x7bf4dedc +1, 365184, 365184, 1728, 1944, 0x7bf4dedc 0, 8320, 8320, 40, 9636, 0x2efb3006, F=0x0 -1, 5733, 5733, 27, 1944, 0x4196c404 -1, 5760, 5760, 27, 1944, 0xcda97c7a +1, 366912, 366912, 1728, 1944, 0x4196c404 +1, 368640, 368640, 1728, 1944, 0xcda97c7a 0, 8360, 8360, 40, 9580, 0x0fb6f4e8, F=0x0 -1, 5787, 5787, 27, 1944, 0x5f4922b2 +1, 370368, 370368, 1728, 1944, 0x5f4922b2 0, 8400, 8400, 40, 7840, 0xe996f564, F=0x0 -1, 5814, 5814, 29, 2088, 0x37dfc157 +1, 372096, 372096, 1856, 2088, 0x37dfc157 0, 8440, 8440, 40, 4208, 0xe9c2fba2, F=0x0 0, 8480, 8480, 40, 556, 0x3f1e077c, F=0x0 -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
