Commit 6c65cf58 authored by Justin Ruggles's avatar Justin Ruggles
Browse files

lavf: Use av_get_audio_frame_duration() in get_audio_frame_size()

Also, do not give AVCodecContext.frame_size priority for muxing.

Updated 2 FATE references:
dxa-feeble - adds 1 audio frame that is still within 2 seconds as specified
             by -t 2 in the FATE test
wmv8-drm-nodec - durations are not needed. previously they were estimated
                 using the packet size and average bit rate.
parent 11ac796f
......@@ -697,27 +697,22 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt)
/**
* Get the number of samples of an audio frame. Return -1 on error.
*/
static int get_audio_frame_size(AVCodecContext *enc, int size)
static int get_audio_frame_size(AVCodecContext *enc, int size, int mux)
{
int frame_size;
if (enc->frame_size <= 1) {
int bits_per_sample = av_get_bits_per_sample(enc->codec_id);
/* give frame_size priority if demuxing */
if (!mux && enc->frame_size > 1)
return enc->frame_size;
if (bits_per_sample) {
if (enc->channels == 0)
return -1;
frame_size = (size << 3) / (bits_per_sample * enc->channels);
} else {
/* used for example by ADPCM codecs */
if (enc->bit_rate == 0)
return -1;
frame_size = ((int64_t)size * 8 * enc->sample_rate) / enc->bit_rate;
}
} else {
frame_size = enc->frame_size;
}
return frame_size;
if ((frame_size = av_get_audio_frame_duration(enc, size)) > 0)
return frame_size;
/* fallback to using frame_size if muxing */
if (enc->frame_size > 1)
return enc->frame_size;
return -1;
}
......@@ -753,7 +748,7 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st,
}
break;
case AVMEDIA_TYPE_AUDIO:
frame_size = get_audio_frame_size(st->codec, pkt->size);
frame_size = get_audio_frame_size(st->codec, pkt->size, 0);
if (frame_size <= 0 || st->codec->sample_rate <= 0)
break;
*pnum = frame_size;
......@@ -2955,7 +2950,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){
/* update pts */
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
frame_size = get_audio_frame_size(st->codec, pkt->size);
frame_size = get_audio_frame_size(st->codec, pkt->size, 1);
/* HACK/FIXME, we skip the initial 0 size packets as they are most
likely equal to the encoder delay, but it would be better if we
......
......@@ -64,3 +64,4 @@
0, 19, 19, 1, 921600, 0x5639e670
1, 21000, 21000, 500, 1000, 0xa491f3ef
1, 21500, 21500, 500, 1000, 0x2c036e18
1, 22000, 22000, 500, 1000, 0x52d65e2a
#tb 0: 1/1000
#tb 1: 1/1000
0, 0, 0, 0, 282, 0x000d949a
1, 0, 0, 435, 1088, 0x5cd379bb
1, 435, 435, 435, 1088, 0x8dfa1368
1, 740, 740, 435, 1088, 0xc0d211be
1, 1023, 1023, 435, 1088, 0x8238113a
1, 0, 0, 0, 1088, 0x5cd379bb
1, 435, 435, 0, 1088, 0x8dfa1368
1, 740, 740, 0, 1088, 0xc0d211be
1, 1023, 1023, 0, 1088, 0x8238113a
0, 1208, 1208, 0, 137, 0x903c415e
0, 1250, 1250, 0, 942, 0xd5b7d2aa
0, 1291, 1291, 0, 841, 0xaffd8ce6
1, 1306, 1306, 435, 1088, 0x9f8924b7
1, 1306, 1306, 0, 1088, 0x9f8924b7
0, 1333, 1333, 0, 1164, 0x4ed84836
0, 1375, 1375, 0, 1492, 0x37f3e8aa
0, 1416, 1416, 0, 1663, 0xc091392d
......@@ -16,14 +16,14 @@
0, 1500, 1500, 0, 1721, 0x7bdb3dd0
0, 1541, 1541, 0, 1410, 0xde689881
0, 1583, 1583, 0, 1258, 0xb5b86920
1, 1589, 1589, 435, 1088, 0x767f317a
1, 1589, 1589, 0, 1088, 0x767f317a
0, 1625, 1625, 0, 2050, 0x99b6d7c7
0, 1666, 1666, 0, 1242, 0x9ba35009
0, 1708, 1708, 0, 1630, 0x17f10192
0, 1750, 1750, 0, 1747, 0xbbee59d7
0, 1791, 1791, 0, 1565, 0xb09b00d9
0, 1833, 1833, 0, 1573, 0xd2e62201
1, 1872, 1872, 435, 1088, 0x57000d38
1, 1872, 1872, 0, 1088, 0x57000d38
0, 1875, 1875, 0, 1353, 0x2305a24d
0, 1916, 1916, 0, 1425, 0xf41bbb46
0, 1958, 1958, 0, 1355, 0xfc08a762
......@@ -32,7 +32,7 @@
0, 2083, 2083, 0, 1967, 0x43d61723
0, 2125, 2125, 0, 1378, 0xde22c753
0, 2166, 2166, 0, 961, 0x2418a4da
1, 2198, 2198, 435, 1088, 0xad977261
1, 2198, 2198, 0, 1088, 0xad977261
0, 2208, 2208, 0, 968, 0x0d04ba51
0, 2250, 2250, 0, 1140, 0x737f3543
0, 2291, 2291, 0, 1119, 0x3c050388
......@@ -64,7 +64,7 @@
0, 3375, 3375, 41, 1408, 0x5585c25c
0, 3416, 3416, 41, 1551, 0x42002c8d
0, 3458, 3458, 41, 1524, 0xbcb609e3
1, 3482, 3482, 435, 1088, 0xdce57471
1, 3482, 3482, 0, 1088, 0xdce57471
0, 3500, 3500, 41, 1554, 0x3d740564
0, 3541, 3541, 41, 1467, 0xc349f2d7
0, 3583, 3583, 41, 1066, 0xb7401462
......@@ -76,7 +76,7 @@
0, 3833, 3833, 41, 1175, 0x12ad3c1e
0, 3875, 3875, 41, 1179, 0x7e034570
0, 3916, 3916, 41, 1136, 0x5c633c51
1, 3918, 3918, 435, 1088, 0xf3887977
1, 3918, 3918, 0, 1088, 0xf3887977
0, 3958, 3958, 41, 1064, 0x5eb51d89
0, 4000, 4000, 41, 953, 0xe148bbdd
0, 4041, 4041, 41, 989, 0x901ec306
......@@ -87,7 +87,7 @@
0, 4250, 4250, 41, 1348, 0x27cfa91b
0, 4291, 4291, 41, 1417, 0x2312d70e
0, 4333, 4333, 41, 1285, 0x46ca4cca
1, 4353, 4353, 435, 1088, 0x1d6c8ed2
1, 4353, 4353, 0, 1088, 0x1d6c8ed2
0, 4375, 4375, 41, 1037, 0xcf09dd3d
0, 4416, 4416, 41, 1005, 0xe780cf1f
0, 4458, 4458, 41, 890, 0x8b1d8c1b
......@@ -95,7 +95,7 @@
0, 4541, 4541, 41, 803, 0x935e775e
0, 4583, 4583, 41, 1035, 0x6a220483
0, 4625, 4625, 41, 466, 0xd88bb237
1, 4789, 4789, 435, 1088, 0x09115bae
1, 4789, 4789, 0, 1088, 0x09115bae
0, 4916, 4916, 41, 945, 0x8f2eb1ec
0, 4958, 4958, 41, 1190, 0x4c451c1b
0, 5000, 5000, 41, 1811, 0x727c52cb
......@@ -104,7 +104,7 @@
0, 5125, 5125, 41, 1707, 0x3d1a6464
0, 5166, 5166, 41, 1103, 0x06b22710
0, 5208, 5208, 41, 1122, 0x656725b8
1, 5224, 5224, 435, 1088, 0x0c8b9372
1, 5224, 5224, 0, 1088, 0x0c8b9372
0, 5250, 5250, 41, 1150, 0xf9674678
0, 5291, 5291, 41, 1438, 0x03fac426
0, 5333, 5333, 41, 1623, 0x7adb1321
......@@ -115,7 +115,7 @@
0, 5541, 5541, 41, 1262, 0xb994692f
0, 5583, 5583, 41, 2097, 0xf4eb663f
0, 5625, 5625, 41, 1251, 0xfd4f633a
1, 5659, 5659, 435, 1088, 0x75a82540
1, 5659, 5659, 0, 1088, 0x75a82540
0, 5666, 5666, 41, 1633, 0xb7e1290e
0, 5708, 5708, 41, 1739, 0xecd18c38
0, 5750, 5750, 41, 1132, 0xc83e1828
......@@ -125,7 +125,7 @@
0, 5916, 5916, 41, 1340, 0xeaa2a231
0, 5958, 5958, 41, 1102, 0x82de2889
0, 6000, 6000, 41, 1834, 0x59b99b92
1, 6008, 6008, 435, 1088, 0x690312b0
1, 6008, 6008, 0, 1088, 0x690312b0
0, 6041, 6041, 41, 1332, 0x0610813a
0, 6083, 6083, 41, 1275, 0x5b0d7be7
0, 6125, 6125, 41, 1376, 0xd915b0fe
......@@ -133,7 +133,7 @@
0, 6208, 6208, 41, 1360, 0x3bcd93d3
0, 6250, 6250, 41, 1330, 0xd0439c93
0, 6291, 6291, 41, 1562, 0xb2560a09
1, 6312, 6312, 435, 1088, 0x76d50ff3
1, 6312, 6312, 0, 1088, 0x76d50ff3
0, 6333, 6333, 41, 1376, 0x4f9eb447
0, 6375, 6375, 41, 1405, 0x85d3b084
0, 6416, 6416, 41, 1344, 0xcdbda2ae
......@@ -141,12 +141,12 @@
0, 6500, 6500, 41, 1459, 0xf9d2c56f
0, 6541, 6541, 41, 1275, 0xf5536d81
0, 6583, 6583, 41, 1209, 0x3b5b4ea5
1, 6595, 6595, 435, 1088, 0x8766276f
1, 6595, 6595, 0, 1088, 0x8766276f
0, 6625, 6625, 41, 1352, 0x7b199d28
0, 6666, 6666, 41, 1349, 0x02adaaf3
0, 6708, 6708, 41, 1464, 0x20d7cfd2
0, 6750, 6750, 41, 1377, 0x78e0b1f4
0, 6791, 6791, 41, 289, 0x1f2e9246
1, 6878, 6878, 435, 1088, 0x678f20fd
1, 7161, 7161, 435, 1088, 0x718afa20
1, 7444, 7444, 435, 1088, 0x758f0939
1, 6878, 6878, 0, 1088, 0x678f20fd
1, 7161, 7161, 0, 1088, 0x718afa20
1, 7444, 7444, 0, 1088, 0x758f0939
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment