avcodec/avcodec.h: add AV_CODEC_ID_TTML
[ffmpeg.git] / tools / sidxindex.c
index e376428..a4f9551 100644 (file)
@@ -52,22 +52,23 @@ struct Tracks {
     int multiple_tracks_per_file;
 };
 
-static void set_codec_str(AVCodecContext *codec, char *str, int size)
+static void set_codec_str(AVCodecParameters *codecpar, char *str, int size)
 {
-    switch (codec->codec_id) {
+    switch (codecpar->codec_id) {
     case AV_CODEC_ID_H264:
         snprintf(str, size, "avc1");
-        if (codec->extradata_size >= 4 && codec->extradata[0] == 1) {
+        if (codecpar->extradata_size >= 4 && codecpar->extradata[0] == 1) {
             av_strlcatf(str, size, ".%02x%02x%02x",
-                        codec->extradata[1], codec->extradata[2], codec->extradata[3]);
+                        codecpar->extradata[1], codecpar->extradata[2],
+                        codecpar->extradata[3]);
         }
         break;
     case AV_CODEC_ID_AAC:
         snprintf(str, size, "mp4a.40"); // 0x40 is the mp4 object type for AAC
-        if (codec->extradata_size >= 2) {
-            int aot = codec->extradata[0] >> 3;
+        if (codecpar->extradata_size >= 2) {
+            int aot = codecpar->extradata[0] >> 3;
             if (aot == 31)
-                aot = ((AV_RB16(codec->extradata) >> 5) & 0x3f) + 32;
+                aot = ((AV_RB16(codecpar->extradata) >> 5) & 0x3f) + 32;
             av_strlcatf(str, size, ".%d", aot);
         }
         break;
@@ -145,7 +146,7 @@ static int handle_file(struct Tracks *tracks, const char *file)
         struct Track **temp;
         AVStream *st = ctx->streams[i];
 
-        if (st->codec->bit_rate == 0) {
+        if (st->codecpar->bit_rate == 0) {
             fprintf(stderr, "Skipping track %d in %s as it has zero bitrate\n",
                     st->id, file);
             continue;
@@ -156,8 +157,8 @@ static int handle_file(struct Tracks *tracks, const char *file)
             err = AVERROR(ENOMEM);
             goto fail;
         }
-        temp = av_realloc(tracks->tracks,
-                          sizeof(*tracks->tracks) * (tracks->nb_tracks + 1));
+        temp = av_realloc_array(tracks->tracks, tracks->nb_tracks + 1,
+                                sizeof(*tracks->tracks));
         if (!temp) {
             av_free(track);
             err = AVERROR(ENOMEM);
@@ -170,12 +171,12 @@ static int handle_file(struct Tracks *tracks, const char *file)
         if ((ptr = strrchr(file, '/')))
             track->name = ptr + 1;
 
-        track->bitrate   = st->codec->bit_rate;
+        track->bitrate   = st->codecpar->bit_rate;
         track->track_id  = st->id;
         track->timescale = st->time_base.den;
         track->duration  = st->duration;
-        track->is_audio  = st->codec->codec_type == AVMEDIA_TYPE_AUDIO;
-        track->is_video  = st->codec->codec_type == AVMEDIA_TYPE_VIDEO;
+        track->is_audio  = st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO;
+        track->is_video  = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO;
 
         if (!track->is_audio && !track->is_video) {
             fprintf(stderr,
@@ -190,14 +191,14 @@ static int handle_file(struct Tracks *tracks, const char *file)
                                                 track->timescale, AV_ROUND_UP));
 
         if (track->is_audio) {
-            track->channels    = st->codec->channels;
-            track->sample_rate = st->codec->sample_rate;
+            track->channels    = st->codecpar->channels;
+            track->sample_rate = st->codecpar->sample_rate;
         }
         if (track->is_video) {
-            track->width  = st->codec->width;
-            track->height = st->codec->height;
+            track->width  = st->codecpar->width;
+            track->height = st->codecpar->height;
         }
-        set_codec_str(st->codec, track->codec_str, sizeof(track->codec_str));
+        set_codec_str(st->codecpar, track->codec_str, sizeof(track->codec_str));
 
         tracks->nb_tracks++;
     }
@@ -244,7 +245,7 @@ static int output_mpd(struct Tracks *tracks, const char *filename)
         nb_tracks = nb_tracks_buf;
         nb_sets = 2;
         for (i = 0; i < 2; i++) {
-            adaptation_sets[i] = av_malloc(sizeof(*adaptation_sets[i]) * tracks->nb_tracks);
+            adaptation_sets[i] = av_malloc_array(tracks->nb_tracks, sizeof(*adaptation_sets[i]));
             if (!adaptation_sets[i]) {
                 ret = AVERROR(ENOMEM);
                 goto err;
@@ -362,8 +363,6 @@ int main(int argc, char **argv)
     struct Tracks tracks = { 0 };
     int i;
 
-    av_register_all();
-
     for (i = 1; i < argc; i++) {
         if (!strcmp(argv[i], "-out")) {
             out = argv[i + 1];