diff options
author | Reuben Martin <reuben.m@gmail.com> | 2013-06-12 23:17:21 -0500 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-07-25 22:01:12 +0200 |
commit | 4a60df2d35e7f297c8a02a21f44a47ea7070f94c (patch) | |
tree | e16c80ecad6ecf3791b5bec10167b98b12ba0257 /libavformat/gxfenc.c | |
parent | de0a1f63dff904fc30361e793400b7b9e427e31d (diff) | |
download | ffmpeg-4a60df2d35e7f297c8a02a21f44a47ea7070f94c.tar.gz |
avformat/gxfenc: Added support for writing correct auxiliary data for DV streams.
Different aux data is written for DVCAM and DVPRO formats.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/gxfenc.c')
-rw-r--r-- | libavformat/gxfenc.c | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 9322f7b88b..84119345a3 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -217,12 +217,27 @@ static int gxf_write_mpeg_auxiliary(AVIOContext *pb, AVStream *st) return size + 3; } +static int gxf_write_dv_auxiliary(AVIOContext *pb, AVStream *st) +{ + int64_t track_aux_data = 0; + + avio_w8(pb, TRACK_AUX); + avio_w8(pb, 8); + if (st->codec->pix_fmt == PIX_FMT_YUV420P) + track_aux_data |= 0x01; /* marks stream as DVCAM instead of DVPRO */ + track_aux_data |= 0x40000000; /* aux data is valid */ + avio_wl64(pb, track_aux_data); + return 8; +} + static int gxf_write_timecode_auxiliary(AVIOContext *pb, GXFContext *gxf) { uint32_t timecode = GXF_TIMECODE(gxf->tc.color, gxf->tc.drop, gxf->tc.hh, gxf->tc.mm, gxf->tc.ss, gxf->tc.ff); + avio_w8(pb, TRACK_AUX); + avio_w8(pb, 8); avio_wl32(pb, timecode); /* reserved */ avio_wl32(pb, 0); @@ -234,7 +249,6 @@ static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc, GXFContext *gxf = s->priv_data; AVIOContext *pb = s->pb; int64_t pos; - int mpeg = sc->track_type == 4 || sc->track_type == 9; /* track description section */ avio_w8(pb, sc->media_type + 0x80); @@ -250,13 +264,21 @@ static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc, avio_wb16(pb, sc->media_info); avio_w8(pb, 0); - if (!mpeg) { - /* auxiliary information */ - avio_w8(pb, TRACK_AUX); - avio_w8(pb, 8); - if (sc->track_type == 3) + switch (sc->track_type) { + case 3: /* timecode */ gxf_write_timecode_auxiliary(pb, gxf); - else + break; + case 4: /* MPEG2 */ + case 9: /* MPEG1 */ + gxf_write_mpeg_auxiliary(pb, s->streams[index]); + break; + case 5: /* DV25 */ + case 6: /* DV50 */ + gxf_write_dv_auxiliary(pb, s->streams[index]); + break; + default: + avio_w8(pb, TRACK_AUX); + avio_w8(pb, 8); avio_wl64(pb, 0); } @@ -265,9 +287,6 @@ static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc, avio_w8(pb, 4); avio_wb32(pb, 0); - if (mpeg) - gxf_write_mpeg_auxiliary(pb, s->streams[index]); - /* frame rate */ avio_w8(pb, TRACK_FPS); avio_w8(pb, 4); @@ -534,13 +553,20 @@ static int gxf_write_umf_media_timecode(AVIOContext *pb, int drop) return 32; } -static int gxf_write_umf_media_dv(AVIOContext *pb, GXFStreamContext *sc) +static int gxf_write_umf_media_dv(AVIOContext *pb, GXFStreamContext *sc, AVStream *st) { - int i; + int dv_umf_data = 0; - for (i = 0; i < 8; i++) { - avio_wb32(pb, 0); - } + if (st->codec->pix_fmt == PIX_FMT_YUV420P) + dv_umf_data |= 0x20; /* marks as DVCAM instead of DVPRO */ + avio_wl32(pb, dv_umf_data); + avio_wl32(pb, 0); + avio_wl32(pb, 0); + avio_wl32(pb, 0); + avio_wl32(pb, 0); + avio_wl32(pb, 0); + avio_wl32(pb, 0); + avio_wl32(pb, 0); return 32; } @@ -604,7 +630,7 @@ static int gxf_write_umf_media_description(AVFormatContext *s) gxf_write_umf_media_audio(pb, sc); break; case AV_CODEC_ID_DVVIDEO: - gxf_write_umf_media_dv(pb, sc); + gxf_write_umf_media_dv(pb, sc, st); break; } } |