1
From c75ba07f6eb83439bc44e5504152f8ca03097bec Mon Sep 17 00:00:00 2001
2
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <tomas.hardin@codemill.se>
3
Date: Thu, 23 Jun 2011 15:59:33 +0200
4
Subject: [PATCH 14/70] gxf: Fix 25 fps DV material in GXF being misdetected as 50 fps
6
Set DV packet durations using fields_per_frame.
7
This requires turning gxf_stream_info into the demuxer's context for access to the value in gxf_packet().
8
Since MPEG-2 seems to work fine this done only for DV.
10
Signed-off-by: Anton Khirnov <anton@khirnov.net>
11
(cherry picked from commit 99fecc64b064a013559d3d61f7d9790e3c95c80e)
13
Signed-off-by: Anton Khirnov <anton@khirnov.net>
15
libavformat/gxf.c | 25 ++++++++++++++++---------
16
1 files changed, 16 insertions(+), 9 deletions(-)
18
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
19
index 74d925f..d77fd18 100644
20
--- a/libavformat/gxf.c
21
+++ b/libavformat/gxf.c
22
@@ -264,7 +264,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
25
AVRational main_timebase = {0, 0};
26
- struct gxf_stream_info si;
27
+ struct gxf_stream_info *si = s->priv_data;
29
if (!parse_packet_header(pb, &pkt_type, &map_len) || pkt_type != PKT_MAP) {
30
av_log(s, AV_LOG_ERROR, "map packet not found\n");
31
@@ -282,7 +282,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
35
- gxf_material_tags(pb, &len, &si);
36
+ gxf_material_tags(pb, &len, si);
39
len = avio_rb16(pb); // length of track description
40
@@ -300,7 +300,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
41
track_id = avio_r8(pb);
42
track_len = avio_rb16(pb);
44
- gxf_track_tags(pb, &track_len, &si);
45
+ gxf_track_tags(pb, &track_len, si);
46
avio_skip(pb, track_len);
47
if (!(track_type & 0x80)) {
48
av_log(s, AV_LOG_ERROR, "invalid track type %x\n", track_type);
49
@@ -316,12 +316,12 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
50
if (idx < 0) continue;
52
if (!main_timebase.num || !main_timebase.den) {
53
- main_timebase.num = si.frames_per_second.den;
54
- main_timebase.den = si.frames_per_second.num * 2;
55
+ main_timebase.num = si->frames_per_second.den;
56
+ main_timebase.den = si->frames_per_second.num * 2;
58
- st->start_time = si.first_field;
59
- if (si.first_field != AV_NOPTS_VALUE && si.last_field != AV_NOPTS_VALUE)
60
- st->duration = si.last_field - si.first_field;
61
+ st->start_time = si->first_field;
62
+ if (si->first_field != AV_NOPTS_VALUE && si->last_field != AV_NOPTS_VALUE)
63
+ st->duration = si->last_field - si->first_field;
66
av_log(s, AV_LOG_ERROR, "invalid track description length specified\n");
67
@@ -422,6 +422,8 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
68
AVIOContext *pb = s->pb;
71
+ struct gxf_stream_info *si = s->priv_data;
73
while (!pb->eof_reached) {
75
int track_type, track_id, ret;
76
@@ -473,6 +475,11 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
78
pkt->stream_index = stream_index;
81
+ //set duration manually for DV or else lavf misdetects the frame rate
82
+ if (st->codec->codec_id == CODEC_ID_DVVIDEO)
83
+ pkt->duration = si->fields_per_frame;
88
@@ -518,7 +525,7 @@ static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index,
89
AVInputFormat ff_gxf_demuxer = {
91
NULL_IF_CONFIG_SMALL("GXF format"),
93
+ sizeof(struct gxf_stream_info),