]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/r3d.c
avidec: make print_tag() a macro and remove related ifdefs
[ffmpeg] / libavformat / r3d.c
index b645d928a0d57bd081cba680cb73c0f05a919ef9..556a32b20eb52b14ac77d52bbec2283fe2b2c352 100644 (file)
@@ -55,8 +55,8 @@ static int r3d_read_red1(AVFormatContext *s)
     int tmp, tmp2;
 
     if (!st)
-        return -1;
-    st->codec->codec_type = CODEC_TYPE_VIDEO;
+        return AVERROR(ENOMEM);
+    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codec->codec_id = CODEC_ID_JPEG2000;
 
     tmp  = get_byte(s->pb); // major version
@@ -87,7 +87,9 @@ static int r3d_read_red1(AVFormatContext *s)
     dprintf(s, "audio channels %d\n", tmp);
     if (tmp > 0) {
         AVStream *ast = av_new_stream(s, 1);
-        ast->codec->codec_type = CODEC_TYPE_AUDIO;
+        if (!ast)
+            return AVERROR(ENOMEM);
+        ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
         ast->codec->codec_id = CODEC_ID_PCM_S32BE;
         ast->codec->channels = tmp;
         av_set_pts_info(ast, 32, 1, st->time_base.den);
@@ -95,7 +97,7 @@ static int r3d_read_red1(AVFormatContext *s)
 
     get_buffer(s->pb, filename, 257);
     filename[sizeof(filename)-1] = 0;
-    av_metadata_set(&st->metadata, "filename", filename);
+    av_metadata_set2(&st->metadata, "filename", filename, 0);
 
     dprintf(s, "filename %s\n", filename);
     dprintf(s, "resolution %dx%d\n", st->codec->width, st->codec->height);
@@ -210,6 +212,7 @@ static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
     int tmp, tmp2;
     uint64_t pos = url_ftell(s->pb);
     unsigned dts;
+    int ret;
 
     dts = get_be32(s->pb);
 
@@ -241,8 +244,8 @@ static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
     tmp = atom->size - 8 - (url_ftell(s->pb) - pos);
     if (tmp < 0)
         return -1;
-
-    if (av_get_packet(s->pb, pkt, tmp) != tmp) {
+    ret = av_get_packet(s->pb, pkt, tmp);
+    if (ret < 0) {
         av_log(s, AV_LOG_ERROR, "error reading video packet\n");
         return -1;
     }
@@ -263,6 +266,7 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
     int tmp, tmp2, samples, size;
     uint64_t pos = url_ftell(s->pb);
     unsigned dts;
+    int ret;
 
     dts = get_be32(s->pb);
 
@@ -286,9 +290,10 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
     size = atom->size - 8 - (url_ftell(s->pb) - pos);
     if (size < 0)
         return -1;
-    if (av_get_packet(s->pb, pkt, size) != size) {
-        av_log(s, AV_LOG_ERROR, "error reading video packet\n");
-        return -1;
+    ret = av_get_packet(s->pb, pkt, size);
+    if (ret < 0) {
+        av_log(s, AV_LOG_ERROR, "error reading audio packet\n");
+        return ret;
     }
 
     pkt->stream_index = 1;