]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/gxfenc.c
flvdec: follow packets backward until a valid last timestamp is found
[ffmpeg] / libavformat / gxfenc.c
index 089a68940289e4d700dd653af3d93b0b3cbdf402..c1a2bb599c97e10bc209838ab6f0d4b99adfa903 100644 (file)
@@ -41,7 +41,6 @@ typedef struct GXFTimecode{
     int ff;
     int color;
     int drop;
-    char *str;
 } GXFTimecode;
 
 typedef struct GXFStreamContext {
@@ -655,11 +654,11 @@ static void gxf_init_timecode_track(GXFStreamContext *sc, GXFStreamContext *vsc)
     sc->fields = vsc->fields;
 }
 
-static int gxf_init_timecode(AVFormatContext *s, GXFTimecode *tc, int fields)
+static int gxf_init_timecode(AVFormatContext *s, GXFTimecode *tc, const char *tcstr, int fields)
 {
     char c;
 
-    if (sscanf(tc->str, "%d:%d:%d%c%d", &tc->hh, &tc->mm, &tc->ss, &c, &tc->ff) != 5) {
+    if (sscanf(tcstr, "%d:%d:%d%c%d", &tc->hh, &tc->mm, &tc->ss, &c, &tc->ff) != 5) {
         av_log(s, AV_LOG_ERROR, "unable to parse timecode, "
                                 "syntax: hh:mm:ss[:;.]ff\n");
         return -1;
@@ -681,6 +680,7 @@ static int gxf_write_header(AVFormatContext *s)
     GXFStreamContext *vsc = NULL;
     uint8_t tracks[255] = {0};
     int i, media_info = 0;
+    AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
 
     if (!pb->seekable) {
         av_log(s, AV_LOG_ERROR, "gxf muxer does not support streamed output, patch welcome");
@@ -741,6 +741,8 @@ static int gxf_write_header(AVFormatContext *s)
                        "gxf muxer only accepts PAL or NTSC resolutions currently\n");
                 return -1;
             }
+            if (!tcr)
+                tcr = av_dict_get(st->metadata, "timecode", NULL, 0);
             avpriv_set_pts_info(st, 64, gxf->time_base.num, gxf->time_base.den);
             if (gxf_find_lines_index(st) < 0)
                 sc->lines_index = -1;
@@ -792,9 +794,8 @@ static int gxf_write_header(AVFormatContext *s)
     if (ff_audio_interleave_init(s, GXF_samples_per_frame, (AVRational){ 1, 48000 }) < 0)
         return -1;
 
-    if (gxf->tc.str) {
-        gxf_init_timecode(s, &gxf->tc, vsc->fields);
-    }
+    if (tcr)
+        gxf_init_timecode(s, &gxf->tc, tcr->value, vsc->fields);
 
     gxf_init_timecode_track(&gxf->timecode_track, vsc);
     gxf->flags |= 0x200000; // time code track is non-drop frame
@@ -983,21 +984,9 @@ static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pk
                                ff_interleave_packet_per_dts, gxf_compare_field_nb);
 }
 
-static const AVOption options[] = {
-    { AV_TIMECODE_OPTION(GXFContext, tc.str, AV_OPT_FLAG_ENCODING_PARAM) },
-    { NULL }
-};
-
-static const AVClass gxf_muxer_class = {
-    .class_name     = "GXF muxer",
-    .item_name      = av_default_item_name,
-    .option         = options,
-    .version        = LIBAVUTIL_VERSION_INT,
-};
-
 AVOutputFormat ff_gxf_muxer = {
     .name              = "gxf",
-    .long_name         = NULL_IF_CONFIG_SMALL("GXF format"),
+    .long_name         = NULL_IF_CONFIG_SMALL("GXF (General eXchange Format)"),
     .extensions        = "gxf",
     .priv_data_size    = sizeof(GXFContext),
     .audio_codec       = CODEC_ID_PCM_S16LE,
@@ -1006,5 +995,4 @@ AVOutputFormat ff_gxf_muxer = {
     .write_packet      = gxf_write_packet,
     .write_trailer     = gxf_write_trailer,
     .interleave_packet = gxf_interleave_packet,
-    .priv_class        = &gxf_muxer_class,
 };