]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/bmv.c
apedec: Convert to the new bitstream reader
[ffmpeg] / libavformat / bmv.c
index 1077efa5738d6cbbfa9a2ba9bc3b454d9faa7c34..9bc8dda871f39a62369bff55883c50b9798c38ec 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Discworld II BMV demuxer
- * Copyright (c) 2011 Konstantin Shishkov.
+ * Copyright (c) 2011 Konstantin Shishkov
  *
  * This file is part of Libav.
  *
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "internal.h"
 
@@ -38,7 +39,7 @@ typedef struct BMVContext {
     int64_t  audio_pos;
 } BMVContext;
 
-static int bmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
+static int bmv_read_header(AVFormatContext *s)
 {
     AVStream *st, *ast;
     BMVContext *c = s->priv_data;
@@ -46,19 +47,20 @@ static int bmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
     st = avformat_new_stream(s, 0);
     if (!st)
         return AVERROR(ENOMEM);
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = CODEC_ID_BMV_VIDEO;
-    st->codec->width      = 640;
-    st->codec->height     = 429;
-    st->codec->pix_fmt    = PIX_FMT_PAL8;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = AV_CODEC_ID_BMV_VIDEO;
+    st->codecpar->width      = 640;
+    st->codecpar->height     = 429;
+    st->codecpar->format     = AV_PIX_FMT_PAL8;
     avpriv_set_pts_info(st, 16, 1, 12);
     ast = avformat_new_stream(s, 0);
     if (!ast)
         return AVERROR(ENOMEM);
-    ast->codec->codec_type      = AVMEDIA_TYPE_AUDIO;
-    ast->codec->codec_id        = CODEC_ID_BMV_AUDIO;
-    ast->codec->channels        = 2;
-    ast->codec->sample_rate     = 22050;
+    ast->codecpar->codec_type      = AVMEDIA_TYPE_AUDIO;
+    ast->codecpar->codec_id        = AV_CODEC_ID_BMV_AUDIO;
+    ast->codecpar->channels        = 2;
+    ast->codecpar->channel_layout  = AV_CH_LAYOUT_STEREO;
+    ast->codecpar->sample_rate     = 22050;
     avpriv_set_pts_info(ast, 16, 1, 22050);
 
     c->get_next  = 1;
@@ -69,8 +71,7 @@ static int bmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
 static int bmv_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     BMVContext *c = s->priv_data;
-    int type;
-    void *tmp;
+    int type, err;
 
     while (c->get_next) {
         if (s->pb->eof_reached)
@@ -83,10 +84,8 @@ static int bmv_read_packet(AVFormatContext *s, AVPacket *pkt)
         c->size = avio_rl24(s->pb);
         if (!c->size)
             return AVERROR_INVALIDDATA;
-        tmp = av_realloc(c->packet, c->size + 1);
-        if (!tmp)
-            return AVERROR(ENOMEM);
-        c->packet = tmp;
+        if ((err = av_reallocp(&c->packet, c->size + 1)) < 0)
+            return err;
         c->packet[0] = type;
         if (avio_read(s->pb, c->packet + 1, c->size) != c->size)
             return AVERROR(EIO);
@@ -133,5 +132,5 @@ AVInputFormat ff_bmv_demuxer = {
     .read_header    = bmv_read_header,
     .read_packet    = bmv_read_packet,
     .read_close     = bmv_read_close,
-    .extensions     = "bmv"
+    .extensions     = "bmv",
 };