]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/gxfenc.c
Use correct length modifier for size comparison in printf expression, fixes:
[ffmpeg] / libavformat / gxfenc.c
index de4b20820c507facdd090dace76a9ecd05e63ed5..a6f4b7260efb7d58e46d39524bf8ffa8ab145ba7 100644 (file)
@@ -19,7 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/fifo.h"
 #include "avformat.h"
 #include "gxf.h"
 #include "riff.h"
@@ -67,14 +66,9 @@ typedef struct GXFContext {
     unsigned packet_count;
 } GXFContext;
 
-typedef struct GXF_Lines {
-    int height;
-    int index;
-} GXF_Lines;
-
-
-/* FIXME check if it is relevant */
-static const GXF_Lines gxf_lines_tab[] = {
+static const struct {
+    int height, index;
+} gxf_lines_tab[] = {
     { 480,  1 }, /* NTSC */
     { 512,  1 }, /* NTSC + VBI */
     { 576,  2 }, /* PAL */
@@ -99,11 +93,11 @@ static const AVCodecTag gxf_media_types[] = {
     { CODEC_ID_MPEG2VIDEO,  20 }, /* MPEG HD */
     { CODEC_ID_MPEG1VIDEO,  22 }, /* NTSC */
     { CODEC_ID_MPEG1VIDEO,  23 }, /* PAL */
-    { 0, 0 },
+    { CODEC_ID_NONE,         0 },
 };
 
-#define SERVER_PATH "/space/"
-#define ES_NAME_PATTERN "ES."
+#define SERVER_PATH "EXT:/PDR/default/"
+#define ES_NAME_PATTERN "EXT:/PDR/default/ES."
 
 static int gxf_find_lines_index(AVStream *st)
 {
@@ -534,22 +528,19 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
     GXFContext *gxf = s->priv_data;
     ByteIOContext *pb = s->pb;
     int64_t pos;
-    int i;
+    int i, j;
 
     pos = url_ftell(pb);
     gxf->umf_media_offset = pos - gxf->umf_start_offset;
     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 */
         put_le16(pb, sc->media_info);
@@ -559,10 +550,10 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
         put_le32(pb, 0); /* attributes rw, ro */
         put_le32(pb, 0); /* mark in */
         put_le32(pb, gxf->nb_fields); /* mark out */
-        strncpy(buffer, ES_NAME_PATTERN, path_size);
-        put_buffer(pb, (uint8_t *)buffer, path_size);
+        put_buffer(pb, ES_NAME_PATTERN, sizeof(ES_NAME_PATTERN));
         put_be16(pb, sc->media_info);
-        put_buffer(pb, (uint8_t *)buffer + path_size + 2, 88 - path_size - 2);
+        for (j = sizeof(ES_NAME_PATTERN)+2; j < 88; j++)
+            put_byte(pb, 0);
         put_le32(pb, sc->track_type);
         put_le32(pb, sc->sample_rate);
         put_le32(pb, sc->sample_size);
@@ -572,17 +563,17 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
             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);
-            break;
-        case CODEC_ID_PCM_S16LE:
-            gxf_write_umf_media_audio(pb, sc);
-            break;
-        case CODEC_ID_DVVIDEO:
-            gxf_write_umf_media_dv(pb, sc);
-            break;
-        }
+            switch (st->codec->codec_id) {
+            case CODEC_ID_MPEG2VIDEO:
+                gxf_write_umf_media_mpeg(pb, st);
+                break;
+            case CODEC_ID_PCM_S16LE:
+                gxf_write_umf_media_audio(pb, sc);
+                break;
+            case CODEC_ID_DVVIDEO:
+                gxf_write_umf_media_dv(pb, sc);
+                break;
+            }
         }
 
         curpos = url_ftell(pb);
@@ -652,8 +643,8 @@ static int gxf_write_header(AVFormatContext *s)
             return AVERROR(ENOMEM);
         st->priv_data = sc;
 
-        sc->media_type = codec_get_tag(gxf_media_types, st->codec->codec_id);
-        if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
+        sc->media_type = ff_codec_get_tag(gxf_media_types, st->codec->codec_id);
+        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
             if (st->codec->codec_id != CODEC_ID_PCM_S16LE) {
                 av_log(s, AV_LOG_ERROR, "only 16 BIT PCM LE allowed for now\n");
                 return -1;
@@ -676,7 +667,7 @@ static int gxf_write_header(AVFormatContext *s)
             gxf->audio_tracks++;
             gxf->flags |= 0x04000000; /* audio is 16 bit pcm */
             media_info = 'A';
-        } else if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+        } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
             if (i != 0) {
                 av_log(s, AV_LOG_ERROR, "video stream must be the first track\n");
                 return -1;
@@ -820,7 +811,7 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
     /* If the video is frame-encoded, the frame numbers shall be represented by
      * even field numbers.
      * see SMPTE360M-2004  6.4.2.1.3 Media field number */
-    if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+    if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
         field_nb = gxf->nb_fields;
     } else {
         field_nb = av_rescale_rnd(pkt->dts, gxf->time_base.den,
@@ -830,7 +821,7 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
     put_byte(pb, sc->media_type);
     put_byte(pb, st->index);
     put_be32(pb, field_nb);
-    if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
+    if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
         put_be16(pb, 0);
         put_be16(pb, size / 2);
     } else if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO) {
@@ -868,13 +859,13 @@ static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
     gxf_write_packet_header(pb, PKT_MEDIA);
     if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
         padding = 4 - pkt->size % 4;
-    else if (st->codec->codec_type == CODEC_TYPE_AUDIO)
+    else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
         padding = GXF_AUDIO_PACKET_SIZE - pkt->size;
     gxf_write_media_preamble(s, pkt, pkt->size + padding);
     put_buffer(pb, pkt->data, pkt->size);
     gxf_write_padding(pb, padding);
 
-    if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+    if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
         if (!(gxf->flt_entries_nb % 500)) {
             gxf->flt_entries = av_realloc(gxf->flt_entries,
                                           (gxf->flt_entries_nb+500)*sizeof(*gxf->flt_entries));
@@ -910,7 +901,7 @@ static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cu
     for (i = 0; i < 2; i++) {
         AVStream *st = s->streams[pkt[i]->stream_index];
         sc[i] = st->priv_data;
-        if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
+        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
             field_nb[i] = av_rescale_rnd(pkt[i]->dts, gxf->time_base.den,
                                          (int64_t)48000*gxf->time_base.num, AV_ROUND_UP);
             field_nb[i] &= ~1; // compare against even field number because audio must be before video
@@ -924,7 +915,7 @@ static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cu
 
 static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
 {
-    if (pkt && s->streams[pkt->stream_index]->codec->codec_type == CODEC_TYPE_VIDEO)
+    if (pkt && s->streams[pkt->stream_index]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
         pkt->duration = 2; // enforce 2 fields
     return ff_audio_rechunk_interleave(s, out, pkt, flush,
                                av_interleave_packet_per_dts, gxf_compare_field_nb);