[FFmpeg-cvslog] r17890 - in trunk: libavformat/gxfenc.c tests/seek.regression.ref
bcoudurier
subversion
Mon Mar 9 01:14:56 CET 2009
Author: bcoudurier
Date: Mon Mar 9 01:14:55 2009
New Revision: 17890
Log:
write timecode track in gxf
Modified:
trunk/libavformat/gxfenc.c
trunk/tests/seek.regression.ref
Modified: trunk/libavformat/gxfenc.c
==============================================================================
--- trunk/libavformat/gxfenc.c Sun Mar 8 23:23:44 2009 (r17889)
+++ trunk/libavformat/gxfenc.c Mon Mar 9 01:14:55 2009 (r17890)
@@ -58,6 +58,7 @@ typedef struct GXFContext {
uint16_t umf_media_size;
int sample_rate;
int flags;
+ GXFStreamContext timecode_track;
} GXFContext;
typedef struct GXF_Lines {
@@ -198,7 +199,6 @@ static int gxf_write_mpeg_auxiliary(Byte
static int gxf_write_timecode_auxiliary(ByteIOContext *pb, GXFStreamContext *sc)
{
- /* FIXME implement that */
put_byte(pb, 0); /* fields */
put_byte(pb, 0); /* seconds */
put_byte(pb, 0); /* minutes */
@@ -208,14 +208,15 @@ static int gxf_write_timecode_auxiliary(
return 8;
}
-static int gxf_write_track_description(ByteIOContext *pb, AVStream *st)
+static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc, int index)
{
- GXFStreamContext *sc = st->priv_data;
+ ByteIOContext *pb = s->pb;
int64_t pos;
+ int mpeg = sc->track_type == 4 || sc->track_type == 9;
/* track description section */
put_byte(pb, sc->media_type + 0x80);
- put_byte(pb, st->index + 0xC0);
+ put_byte(pb, index + 0xC0);
pos = url_ftell(pb);
put_be16(pb, 0); /* size */
@@ -227,11 +228,11 @@ static int gxf_write_track_description(B
put_be16(pb, sc->media_info);
put_byte(pb, 0);
- if (st->codec->codec_id != CODEC_ID_MPEG2VIDEO) {
+ if (!mpeg) {
/* auxiliary information */
put_byte(pb, TRACK_AUX);
put_byte(pb, 8);
- if (st->codec->codec_id == CODEC_ID_NONE)
+ if (sc->track_type == 3)
gxf_write_timecode_auxiliary(pb, sc);
else
put_le64(pb, 0);
@@ -242,8 +243,8 @@ static int gxf_write_track_description(B
put_byte(pb, 4);
put_be32(pb, 0);
- if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO)
- gxf_write_mpeg_auxiliary(pb, st);
+ if (mpeg)
+ gxf_write_mpeg_auxiliary(pb, s->streams[index]);
/* frame rate */
put_byte(pb, TRACK_FPS);
@@ -313,6 +314,7 @@ static int gxf_write_material_data_secti
static int gxf_write_track_description_section(AVFormatContext *s)
{
+ GXFContext *gxf = s->priv_data;
ByteIOContext *pb = s->pb;
int64_t pos;
int i;
@@ -320,7 +322,10 @@ static int gxf_write_track_description_s
pos = url_ftell(pb);
put_be16(pb, 0); /* size */
for (i = 0; i < s->nb_streams; ++i)
- gxf_write_track_description(pb, s->streams[i]);
+ gxf_write_track_description(s, s->streams[i]->priv_data, i);
+
+ gxf_write_track_description(s, &gxf->timecode_track, s->nb_streams);
+
return updateSize(pb, pos);
}
@@ -385,7 +390,7 @@ static int gxf_write_umf_material_descri
put_le16(pb, 0); /* reserved */
put_le16(pb, 0); /* reserved */
put_le16(pb, gxf->audio_tracks);
- put_le16(pb, 0); /* timecode track count */
+ put_le16(pb, 1); /* timecode track count */
put_le16(pb, 0); /* reserved */
put_le16(pb, gxf->mpeg_tracks);
return 48;
@@ -398,10 +403,10 @@ static int gxf_write_umf_payload(AVForma
put_le32(pb, gxf->umf_length); /* total length of the umf data */
put_le32(pb, 3); /* version */
- put_le32(pb, s->nb_streams);
+ put_le32(pb, s->nb_streams+1);
put_le32(pb, gxf->umf_track_offset); /* umf track section offset */
put_le32(pb, gxf->umf_track_size);
- put_le32(pb, s->nb_streams);
+ put_le32(pb, s->nb_streams+1);
put_le32(pb, gxf->umf_media_offset);
put_le32(pb, gxf->umf_media_size);
put_le32(pb, gxf->umf_length); /* user data offset */
@@ -424,6 +429,10 @@ static int gxf_write_umf_track_descripti
put_le16(pb, sc->media_info);
put_le16(pb, 1);
}
+
+ put_le16(pb, gxf->timecode_track.media_info);
+ put_le16(pb, 1);
+
return url_ftell(pb) - pos;
}
@@ -452,15 +461,14 @@ static int gxf_write_umf_media_mpeg(Byte
static int gxf_write_umf_media_timecode(ByteIOContext *pb, GXFStreamContext *sc)
{
- /* FIXME implement */
- put_be32(pb, 0); /* drop frame flag */
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
- put_be32(pb, 0); /* reserved */
+ put_le32(pb, 1); /* non drop frame */
+ put_le32(pb, 0); /* reserved */
+ put_le32(pb, 0); /* reserved */
+ put_le32(pb, 0); /* reserved */
+ put_le32(pb, 0); /* reserved */
+ put_le32(pb, 0); /* reserved */
+ put_le32(pb, 0); /* reserved */
+ put_le32(pb, 0); /* reserved */
return 32;
}
@@ -505,13 +513,17 @@ static int gxf_write_umf_media_descripti
pos = url_ftell(pb);
gxf->umf_media_offset = pos - gxf->umf_start_offset;
- for (i = 0; i < s->nb_streams; ++i) {
- AVStream *st = s->streams[i];
- GXFStreamContext *sc = st->priv_data;
+ for (i = 0; i <= s->nb_streams; ++i) {
+ GXFStreamContext *sc;
char buffer[88];
int64_t startpos, curpos;
int path_size = strlen(ES_NAME_PATTERN);
+ if (i == s->nb_streams)
+ sc = &gxf->timecode_track;
+ else
+ sc = s->streams[i]->priv_data;
+
memset(buffer, 0, 88);
startpos = url_ftell(pb);
put_le16(pb, 0); /* length */
@@ -530,6 +542,11 @@ static int gxf_write_umf_media_descripti
put_le32(pb, sc->sample_rate);
put_le32(pb, sc->sample_size);
put_le32(pb, 0); /* reserved */
+
+ if (sc == &gxf->timecode_track)
+ gxf_write_umf_media_timecode(pb, sc); /* 8 0bytes */
+ else {
+ AVStream *st = s->streams[i];
switch (st->codec->codec_id) {
case CODEC_ID_MPEG2VIDEO:
gxf_write_umf_media_mpeg(pb, st);
@@ -540,9 +557,9 @@ static int gxf_write_umf_media_descripti
case CODEC_ID_DVVIDEO:
gxf_write_umf_media_dv(pb, sc);
break;
- default:
- gxf_write_umf_media_timecode(pb, sc); /* 8 0bytes */
}
+ }
+
curpos = url_ftell(pb);
url_fseek(pb, startpos, SEEK_SET);
put_le16(pb, curpos - startpos);
@@ -574,10 +591,26 @@ static int gxf_write_umf_packet(AVFormat
static const int GXF_samples_per_frame[] = { 32768, 0 };
+static void gxf_init_timecode_track(GXFStreamContext *sc, GXFStreamContext *vsc)
+{
+ if (!vsc)
+ return;
+
+ sc->media_type = vsc->sample_rate == 60 ? 7 : 8;
+ sc->sample_rate = vsc->sample_rate;
+ sc->media_info = ('T'<<8) | '0';
+ sc->track_type = 3;
+ sc->frame_rate_index = vsc->frame_rate_index;
+ sc->lines_index = vsc->lines_index;
+ sc->sample_size = 16;
+ sc->fields = vsc->fields;
+}
+
static int gxf_write_header(AVFormatContext *s)
{
ByteIOContext *pb = s->pb;
GXFContext *gxf = s->priv_data;
+ GXFStreamContext *vsc = NULL;
uint8_t tracks[255] = {0};
int i, media_info = 0;
@@ -631,6 +664,9 @@ static int gxf_write_header(AVFormatCont
sc->lines_index = -1;
sc->sample_size = st->codec->bit_rate;
sc->fields = 2; /* interlaced */
+
+ vsc = sc;
+
switch (st->codec->codec_id) {
case CODEC_ID_MJPEG:
sc->track_type = 1;
@@ -673,6 +709,9 @@ static int gxf_write_header(AVFormatCont
if (ff_audio_interleave_init(s, GXF_samples_per_frame, (AVRational){ 1, 48000 }) < 0)
return -1;
+ gxf_init_timecode_track(&gxf->timecode_track, vsc);
+ gxf->flags |= 0x200000; // time code track is non-drop frame
+
gxf_write_map_packet(s);
//gxf_write_flt_packet(s);
gxf_write_umf_packet(s);
Modified: trunk/tests/seek.regression.ref
==============================================================================
--- trunk/tests/seek.regression.ref Sun Mar 8 23:23:44 2009 (r17889)
+++ trunk/tests/seek.regression.ref Mon Mar 9 01:14:55 2009 (r17890)
@@ -2907,59 +2907,59 @@ ret:-22 st:-1 ts:0.460008 flags:0
ret:-22 st:-1 ts:-0.645825 flags:1
----------------
tests/data/b-libav.gxf
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:940 size:55076 flags:1
ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:56048 size:65536 flags:1
ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
ret: 0 st: 0 ts:0.780000 flags:0
-ret: 0 st: 0 dts:0.800000 pts:-184467440737095520.000000 pos:661360 size:22568 flags:0
+ret: 0 st: 0 dts:0.800000 pts:-184467440737095520.000000 pos:661548 size:22568 flags:0
ret: 0 st: 0 ts:-0.320000 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:940 size:55076 flags:1
ret: 0 st: 1 ts:2.580000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
ret: 0 st: 1 ts:1.480000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st:-1 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.360000 pts:-184467440737095520.000000 pos:303896 size:23176 flags:0
-ret: 0 st:-1 ts:-0.740831 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
-ret: 0 st: 0 ts:2.160000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 0 ts:1.040000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 1 ts:-0.060000 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
-ret: 0 st: 1 ts:2.840000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.600000 pts:-184467440737095520.000000 pos:476172 size:23728 flags:0
-ret: 0 st: 0 ts:-0.480000 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
-ret: 0 st: 0 ts:2.420000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 1 ts:1.300000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 1 ts:0.200000 flags:1
-ret: 0 st: 0 dts:0.200000 pts:-184467440737095520.000000 pos:211056 size:20944 flags:0
-ret: 0 st:-1 ts:-0.904994 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
-ret: 0 st:-1 ts:1.989173 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 0 ts:0.880000 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-184467440737095520.000000 pos:706776 size:22456 flags:0
-ret: 0 st: 0 ts:-0.220000 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
-ret: 0 st: 1 ts:2.680000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 1 ts:1.560000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
+ret: 0 st: 2 ts:0.360000 flags:0
+ret: 0 st: 0 dts:0.360000 pts:-184467440737095520.000000 pos:304084 size:23176 flags:0
+ret: 0 st: 2 ts:-0.740000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:940 size:55076 flags:1
+ret: 0 st:-1 ts:2.153336 flags:0
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
+ret: 0 st:-1 ts:1.047503 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
+ret: 0 st: 0 ts:-0.060000 flags:0
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:56048 size:65536 flags:1
+ret: 0 st: 0 ts:2.840000 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
+ret: 0 st: 1 ts:1.740000 flags:0
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
+ret: 0 st: 1 ts:0.620000 flags:1
+ret: 0 st: 0 dts:0.600000 pts:-184467440737095520.000000 pos:476360 size:23728 flags:0
+ret: 0 st: 2 ts:-0.480000 flags:0
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:56048 size:65536 flags:1
+ret: 0 st: 2 ts:2.420000 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
+ret: 0 st:-1 ts:1.306672 flags:0
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
+ret: 0 st:-1 ts:0.200839 flags:1
+ret: 0 st: 0 dts:0.200000 pts:-184467440737095520.000000 pos:211244 size:20944 flags:0
+ret: 0 st: 0 ts:-0.900000 flags:0
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:56048 size:65536 flags:1
+ret: 0 st: 0 ts:1.980000 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
+ret: 0 st: 1 ts:0.880000 flags:0
+ret: 0 st: 0 dts:0.880000 pts:-184467440737095520.000000 pos:706964 size:22456 flags:0
+ret: 0 st: 1 ts:-0.220000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:940 size:55076 flags:1
+ret: 0 st: 2 ts:2.680000 flags:0
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
+ret: 0 st: 2 ts:1.560000 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751848 size:54320 flags:1
ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:-184467440737095520.000000 pos:371520 size:53804 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-184467440737095520.000000 pos:371708 size:53804 flags:1
ret: 0 st:-1 ts:-0.645825 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:940 size:55076 flags:1
----------------
tests/data/b-libav.mkv
ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:505 size:28088 flags:1
More information about the ffmpeg-cvslog
mailing list