According to unofficial documentation, the video rate is locked to the audio
sample rate. This results in proper synchronization of audio and video
timestamps.
---
libavformat/bethsoftvid.c | 8 ++-
tests/ref/fate/bethsoft-vid | 139 ++++++++++++++++++++++---------------------
2 files changed, 76 insertions(+), 71 deletions(-)
diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c
index dc48d7c..f7bc4ae 100644
--- a/libavformat/bethsoftvid.c
+++ b/libavformat/bethsoftvid.c
@@ -34,6 +34,8 @@
#define BVID_PALETTE_SIZE 3 * 256
+#define DEFAULT_SAMPLE_RATE 11111
+
typedef struct BVID_DemuxContext
{
int nframes;
@@ -80,7 +82,7 @@ static int vid_read_header(AVFormatContext *s,
if (!stream)
return AVERROR(ENOMEM);
vid->video_index = stream->index;
- avpriv_set_pts_info(stream, 32, 1, 60); // 16 ms increments, i.e. 60
fps
+ avpriv_set_pts_info(stream, 64, 185, DEFAULT_SAMPLE_RATE);
stream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
stream->codec->codec_id = CODEC_ID_BETHSOFTVID;
stream->codec->width = avio_rl16(pb);
@@ -196,7 +198,7 @@ static int vid_read_packet(AVFormatContext *s,
BVID_DemuxContext *vid = s->priv_data;
AVIOContext *pb = s->pb;
unsigned char block_type;
- int audio_length, sample_rate = 11111;
+ int audio_length, sample_rate = DEFAULT_SAMPLE_RATE;
int ret_value;
if(vid->is_finished || pb->eof_reached)
@@ -235,6 +237,8 @@ static int vid_read_packet(AVFormatContext *s,
st->codec->sample_rate = sample_rate;
st->codec->bit_rate = 8 * st->codec->sample_rate;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(s->streams[vid->video_index], 64, 185,
+ st->codec->sample_rate);
}
audio_length = avio_rl16(pb);
if ((ret_value = av_get_packet(pb, pkt, audio_length)) !=
audio_length) {
diff --git a/tests/ref/fate/bethsoft-vid b/tests/ref/fate/bethsoft-vid
index 92c694b..3779caf 100644
--- a/tests/ref/fate/bethsoft-vid
+++ b/tests/ref/fate/bethsoft-vid
@@ -1,90 +1,91 @@
0, 0, 192000, 0x00000000
1, 0, 1480, 0x00000000
-0, 1500, 192000, 0x01a6cf45
-0, 3000, 192000, 0xd07d57e9
-0, 4500, 192000, 0x3cb1dff5
+0, 1499, 192000, 0x01a6cf45
+0, 2997, 192000, 0xd07d57e9
+0, 4496, 192000, 0x3cb1dff5
+0, 5994, 192000, 0xd1aaa8fb
1, 5994, 1480, 0x20a92bd4
-0, 6000, 192000, 0xd1aaa8fb
-0, 7500, 192000, 0x75f526cd
-0, 9000, 192000, 0x0f673577
-0, 10500, 192000, 0x897b6781
+0, 7493, 192000, 0x75f526cd
+0, 8991, 192000, 0x0f673577
+0, 10490, 192000, 0x897b6781
+0, 11988, 192000, 0x81e6b7f7
1, 11988, 1850, 0xa9e48a74
-0, 12000, 192000, 0x81e6b7f7
-0, 13500, 192000, 0x1f45ce61
-0, 15000, 192000, 0x5a0772a6
-0, 16500, 192000, 0xf78732b3
-0, 18000, 192000, 0x8427f9e5
+0, 13487, 192000, 0x1f45ce61
+0, 14985, 192000, 0x5a0772a6
+0, 16484, 192000, 0xf78732b3
+0, 17982, 192000, 0x8427f9e5
+0, 19481, 192000, 0x40473f11
1, 19481, 1480, 0x23ecd018
-0, 19500, 192000, 0x40473f11
-0, 21000, 192000, 0x173ceebe
-0, 22500, 192000, 0x136b9516
-0, 24000, 192000, 0x138d11ae
+0, 20979, 192000, 0x173ceebe
+0, 22478, 192000, 0x136b9516
+0, 23976, 192000, 0x138d11ae
+0, 25475, 192000, 0x063dbff3
1, 25475, 1480, 0x206bb915
-0, 25500, 192000, 0x063dbff3
-0, 27000, 192000, 0x5280852f
-0, 28500, 192000, 0x99943a8f
-0, 30000, 192000, 0x0330a728
+0, 26973, 192000, 0x5280852f
+0, 28472, 192000, 0x99943a8f
+0, 29970, 192000, 0x0330a728
+0, 31469, 192000, 0x5d35467d
1, 31469, 1850, 0xb0e10e75
-0, 31500, 192000, 0x5d35467d
-0, 33000, 192000, 0xfd436343
-0, 34500, 192000, 0xc323fcfe
-0, 36000, 192000, 0x2a1530a0
-0, 37500, 192000, 0xbd43bb60
+0, 32967, 192000, 0xfd436343
+0, 34466, 192000, 0xc323fcfe
+0, 35964, 192000, 0x2a1530a0
+0, 37463, 192000, 0xbd43bb60
+0, 38961, 192000, 0xa47f5eab
1, 38961, 1480, 0x8d9baedd
-0, 39000, 192000, 0xa47f5eab
-0, 40500, 192000, 0xff17f5f7
-0, 42000, 192000, 0xb4140b55
-0, 43500, 192000, 0xb8782cc4
+0, 40460, 192000, 0xff17f5f7
+0, 41958, 192000, 0xb4140b55
+0, 43457, 192000, 0xb8782cc4
+0, 44955, 192000, 0x92975b8b
1, 44955, 1480, 0xb802aae1
-0, 45000, 192000, 0x92975b8b
-0, 46500, 192000, 0xf42a64d6
-0, 48000, 192000, 0x2cc7077d
-0, 49500, 192000, 0x00080cc8
+0, 46454, 192000, 0xf42a64d6
+0, 47952, 192000, 0x2cc7077d
+0, 49451, 192000, 0x00080cc8
+0, 50950, 192000, 0x584b48f3
1, 50950, 1480, 0xecd7b5cc
-0, 51000, 192000, 0x584b48f3
-0, 52500, 192000, 0xd68f57da
-0, 54000, 192000, 0x60158422
-0, 55500, 192000, 0xd7fb89e6
+0, 52448, 192000, 0xd68f57da
+0, 53947, 192000, 0x60158422
+0, 55445, 192000, 0xd7fb89e6
+0, 56944, 192000, 0x97f1c76a
1, 56944, 1850, 0x16861355
-0, 57000, 192000, 0x97f1c76a
-0, 58500, 192000, 0x46c4bb9e
-0, 60000, 192000, 0xd32f9b66
-0, 61500, 192000, 0x74f43886
-0, 63000, 192000, 0x3c4e47df
+0, 58442, 192000, 0x46c4bb9e
+0, 59941, 192000, 0xd32f9b66
+0, 61439, 192000, 0x74f43886
+0, 62938, 192000, 0x3c4e47df
+0, 64436, 192000, 0xb5ac0a58
1, 64436, 1480, 0xa51690bd
-0, 64500, 192000, 0xb5ac0a58
-0, 66000, 192000, 0xcc572b31
-0, 67500, 192000, 0xb1739d26
-0, 69000, 192000, 0x73da5473
+0, 65935, 192000, 0xcc572b31
+0, 67433, 192000, 0xb1739d26
+0, 68932, 192000, 0x73da5473
+0, 70430, 192000, 0x5f79f5bc
1, 70430, 1480, 0xdd0b90d1
-0, 70500, 192000, 0x5f79f5bc
-0, 72000, 192000, 0x0affc0a0
-0, 73500, 192000, 0x2b4d5c1c
-0, 75000, 192000, 0x309b41bc
+0, 71929, 192000, 0x0affc0a0
+0, 73427, 192000, 0x2b4d5c1c
+0, 74926, 192000, 0x309b41bc
+0, 76424, 192000, 0xd42b6424
1, 76424, 1850, 0x3ce6e333
-0, 76500, 192000, 0xd42b6424
-0, 78000, 192000, 0x4795c948
-0, 79500, 192000, 0xbc1a3a8b
-0, 81000, 192000, 0x16529c5b
-0, 82500, 192000, 0x6b1b31ba
+0, 77923, 192000, 0x4795c948
+0, 79421, 192000, 0xbc1a3a8b
+0, 80920, 192000, 0x16529c5b
+0, 82418, 192000, 0x6b1b31ba
+0, 83917, 192000, 0x569182ce
1, 83917, 1480, 0xf8ce8ea3
-0, 84000, 192000, 0x569182ce
-0, 85500, 192000, 0xe6ea9866
-0, 87000, 192000, 0x102c6076
-0, 88500, 192000, 0xb29f527a
+0, 85415, 192000, 0xe6ea9866
+0, 86914, 192000, 0x102c6076
+0, 88412, 192000, 0xb29f527a
+0, 89911, 192000, 0x040b4eee
1, 89911, 1480, 0xda4597af
-0, 90000, 192000, 0x040b4eee
-0, 91500, 192000, 0x92574f4a
-0, 93000, 192000, 0x1e8acdce
-0, 94500, 192000, 0x1becf516
+0, 91409, 192000, 0x92574f4a
+0, 92908, 192000, 0x1e8acdce
+0, 94406, 192000, 0x1becf516
+0, 95905, 192000, 0xb62e9776
1, 95905, 1480, 0x918f7cb3
-0, 96000, 192000, 0xb62e9776
-0, 97500, 192000, 0xed37a08e
-0, 99000, 192000, 0xc0719912
-0, 100500, 192000, 0x24cf7a7e
+0, 97403, 192000, 0xed37a08e
+0, 98902, 192000, 0xc0719912
+0, 100401, 192000, 0x24cf7a7e
+0, 101899, 192000, 0x0307f62f
1, 101899, 1850, 0xca6edb15
-0, 102000, 192000, 0x0307f62f
-0, 103500, 192000, 0x79b7417b
+0, 103398, 192000, 0x79b7417b
+0, 104896, 192000, 0x468d8db4
1, 109392, 1480, 0xba279597
1, 115386, 1480, 0xc5a38a9e
1, 121380, 1850, 0x8147eef5
--
1.7.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel