]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/c93.c
libavformat: Add av_pkt_dump{, _log}2, taking an AVStream parameter
[ffmpeg] / libavformat / c93.c
index cd3d36a1600c6cba555b2dd9b04d2eeffda3e4a1..a4a0fe3ad080b53e862da839060fb98fa9ec7c61 100644 (file)
@@ -60,15 +60,15 @@ static int read_header(AVFormatContext *s,
                            AVFormatParameters *ap)
 {
     AVStream *video;
-    ByteIOContext *pb = s->pb;
+    AVIOContext *pb = s->pb;
     C93DemuxContext *c93 = s->priv_data;
     int i;
     int framecount = 0;
 
     for (i = 0; i < 512; i++) {
-        c93->block_records[i].index = get_le16(pb);
-        c93->block_records[i].length = get_byte(pb);
-        c93->block_records[i].frames = get_byte(pb);
+        c93->block_records[i].index = avio_rl16(pb);
+        c93->block_records[i].length = avio_r8(pb);
+        c93->block_records[i].frames = avio_r8(pb);
         if (c93->block_records[i].frames > 32) {
             av_log(s, AV_LOG_ERROR, "too many frames in block\n");
             return AVERROR_INVALIDDATA;
@@ -89,7 +89,7 @@ static int read_header(AVFormatContext *s,
     video->codec->height = 192;
     /* 4:3 320x200 with 8 empty lines */
     video->sample_aspect_ratio = (AVRational) { 5, 6 };
-    video->time_base = (AVRational) { 2, 25 };
+    av_set_pts_info(video, 64, 2, 25);
     video->nb_frames = framecount;
     video->duration = framecount;
     video->start_time = 0;
@@ -105,7 +105,7 @@ static int read_header(AVFormatContext *s,
 
 static int read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    ByteIOContext *pb = s->pb;
+    AVIOContext *pb = s->pb;
     C93DemuxContext *c93 = s->priv_data;
     C93BlockRecord *br = &c93->block_records[c93->current_block];
     int datasize;
@@ -114,7 +114,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     if (c93->next_pkt_is_audio) {
         c93->current_frame++;
         c93->next_pkt_is_audio = 0;
-        datasize = get_le16(pb);
+        datasize = avio_rl16(pb);
         if (datasize > 42) {
             if (!c93->audio) {
                 c93->audio = av_new_stream(s, 1);
@@ -122,11 +122,11 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
                     return AVERROR(ENOMEM);
                 c93->audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
             }
-            url_fskip(pb, 26); /* VOC header */
+            avio_seek(pb, 26, SEEK_CUR); /* VOC header */
             ret = voc_get_packet(s, pkt, c93->audio, datasize - 26);
             if (ret > 0) {
                 pkt->stream_index = 1;
-                pkt->flags |= PKT_FLAG_KEY;
+                pkt->flags |= AV_PKT_FLAG_KEY;
                 return ret;
             }
         }
@@ -140,15 +140,15 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     if (c93->current_frame == 0) {
-        url_fseek(pb, br->index * 2048, SEEK_SET);
+        avio_seek(pb, br->index * 2048, SEEK_SET);
         for (i = 0; i < 32; i++) {
-            c93->frame_offsets[i] = get_le32(pb);
+            c93->frame_offsets[i] = avio_rl32(pb);
         }
     }
 
-    url_fseek(pb,br->index * 2048 +
+    avio_seek(pb,br->index * 2048 +
             c93->frame_offsets[c93->current_frame], SEEK_SET);
-    datasize = get_le16(pb); /* video frame size */
+    datasize = avio_rl16(pb); /* video frame size */
 
     ret = av_new_packet(pkt, datasize + 768 + 1);
     if (ret < 0)
@@ -156,13 +156,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->data[0] = 0;
     pkt->size = datasize + 1;
 
-    ret = get_buffer(pb, pkt->data + 1, datasize);
+    ret = avio_read(pb, pkt->data + 1, datasize);
     if (ret < datasize) {
         ret = AVERROR(EIO);
         goto fail;
     }
 
-    datasize = get_le16(pb); /* palette size */
+    datasize = avio_rl16(pb); /* palette size */
     if (datasize) {
         if (datasize != 768) {
             av_log(s, AV_LOG_ERROR, "invalid palette size %u\n", datasize);
@@ -170,7 +170,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
             goto fail;
         }
         pkt->data[0] |= C93_HAS_PALETTE;
-        ret = get_buffer(pb, pkt->data + pkt->size, datasize);
+        ret = avio_read(pb, pkt->data + pkt->size, datasize);
         if (ret < datasize) {
             ret = AVERROR(EIO);
             goto fail;
@@ -182,7 +182,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
 
     /* only the first frame is guaranteed to not reference previous frames */
     if (c93->current_block == 0 && c93->current_frame == 0) {
-        pkt->flags |= PKT_FLAG_KEY;
+        pkt->flags |= AV_PKT_FLAG_KEY;
         pkt->data[0] |= C93_FIRST_FRAME;
     }
     return 0;
@@ -192,7 +192,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     return ret;
 }
 
-AVInputFormat c93_demuxer = {
+AVInputFormat ff_c93_demuxer = {
     "c93",
     NULL_IF_CONFIG_SMALL("Interplay C93"),
     sizeof(C93DemuxContext),