]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/c93.c
lavf: factor out freeing an AVStream
[ffmpeg] / libavformat / c93.c
index 270a09bf6bd007033fb2a43e5ac643397d3684e4..3ae99fcfc92015406047b6d31c4d692c4f82ccf6 100644 (file)
@@ -2,34 +2,35 @@
  * Interplay C93 demuxer
  * Copyright (c) 2007 Anssi Hannula <anssi.hannula@gmail.com>
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include "avformat.h"
+#include "internal.h"
 #include "voc.h"
 #include "libavutil/intreadwrite.h"
 
-typedef struct {
+typedef struct C93BlockRecord {
     uint16_t index;
     uint8_t length;
     uint8_t frames;
 } C93BlockRecord;
 
-typedef struct {
+typedef struct C93DemuxContext {
     VocDecContext voc;
 
     C93BlockRecord block_records[512];
@@ -56,8 +57,7 @@ static int probe(AVProbeData *p)
     return AVPROBE_SCORE_MAX;
 }
 
-static int read_header(AVFormatContext *s,
-                           AVFormatParameters *ap)
+static int read_header(AVFormatContext *s)
 {
     AVStream *video;
     AVIOContext *pb = s->pb;
@@ -79,17 +79,17 @@ static int read_header(AVFormatContext *s,
     /* Audio streams are added if audio packets are found */
     s->ctx_flags |= AVFMTCTX_NOHEADER;
 
-    video = av_new_stream(s, 0);
+    video = avformat_new_stream(s, NULL);
     if (!video)
         return AVERROR(ENOMEM);
 
     video->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    video->codec->codec_id = CODEC_ID_C93;
+    video->codec->codec_id = AV_CODEC_ID_C93;
     video->codec->width = 320;
     video->codec->height = 192;
     /* 4:3 320x200 with 8 empty lines */
     video->sample_aspect_ratio = (AVRational) { 5, 6 };
-    av_set_pts_info(video, 64, 2, 25);
+    avpriv_set_pts_info(video, 64, 2, 25);
     video->nb_frames = framecount;
     video->duration = framecount;
     video->start_time = 0;
@@ -117,13 +117,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
         datasize = avio_rl16(pb);
         if (datasize > 42) {
             if (!c93->audio) {
-                c93->audio = av_new_stream(s, 1);
+                c93->audio = avformat_new_stream(s, NULL);
                 if (!c93->audio)
                     return AVERROR(ENOMEM);
                 c93->audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
             }
             avio_skip(pb, 26); /* VOC header */
-            ret = voc_get_packet(s, pkt, c93->audio, datasize - 26);
+            ret = ff_voc_get_packet(s, pkt, c93->audio, datasize - 26);
             if (ret > 0) {
                 pkt->stream_index = 1;
                 pkt->flags |= AV_PKT_FLAG_KEY;
@@ -188,15 +188,15 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     return 0;
 
     fail:
-    av_free_packet(pkt);
+    av_packet_unref(pkt);
     return ret;
 }
 
 AVInputFormat ff_c93_demuxer = {
-    "c93",
-    NULL_IF_CONFIG_SMALL("Interplay C93"),
-    sizeof(C93DemuxContext),
-    probe,
-    read_header,
-    read_packet,
+    .name           = "c93",
+    .long_name      = NULL_IF_CONFIG_SMALL("Interplay C93"),
+    .priv_data_size = sizeof(C93DemuxContext),
+    .read_probe     = probe,
+    .read_header    = read_header,
+    .read_packet    = read_packet,
 };