]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/bink.c
Fix obviously missing dependency of float DCT.
[ffmpeg] / libavformat / bink.c
index 5f357a47de2b72ae06cc688e6b505c41047671fc..afa629f3551ccdfe94d2c5e5d12881fd04dd31fa 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 /**
- * @file libavformat/bink.c
+ * @file
  * Bink demuxer
  *
  * Technical details here:
@@ -111,7 +111,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
     }
     av_set_pts_info(vst, 64, fps_den, fps_num);
 
-    vst->codec->codec_type = CODEC_TYPE_VIDEO;
+    vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     vst->codec->codec_id   = CODEC_ID_BINKVIDEO;
     vst->codec->extradata  = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE);
     vst->codec->extradata_size = 4;
@@ -133,7 +133,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
             ast = av_new_stream(s, 1);
             if (!ast)
                 return AVERROR(ENOMEM);
-            ast->codec->codec_type  = CODEC_TYPE_AUDIO;
+            ast->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
             ast->codec->codec_tag   = 0;
             ast->codec->sample_rate = get_le16(pb);
             av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
@@ -210,30 +210,30 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
         }
         bink->remain_packet_size -= 4 + audio_size;
         bink->current_track++;
-        if (audio_size > 0) {
-            /* Each audio packet reports the number of decompressed samples
-               (in bytes). We use this value to calcuate the audio PTS */
-            int reported_size = get_le32(pb) / (2 * s->streams[bink->current_track]->codec->channels);
-            url_fseek(pb, -4, SEEK_CUR);
-
+        if (audio_size >= 4) {
             /* get one audio packet per track */
-            if ((ret = av_get_packet(pb, pkt, audio_size))
-                                           != audio_size)
+            if ((ret = av_get_packet(pb, pkt, audio_size)) < 0)
                 return ret;
             pkt->stream_index = bink->current_track;
             pkt->pts = bink->audio_pts[bink->current_track - 1];
-            bink->audio_pts[bink->current_track -1] += reported_size;
+
+            /* Each audio packet reports the number of decompressed samples
+               (in bytes). We use this value to calcuate the audio PTS */
+            if (pkt->size >= 4)
+                bink->audio_pts[bink->current_track -1] +=
+                    AV_RL32(pkt->data) / (2 * s->streams[bink->current_track]->codec->channels);
             return 0;
+        } else {
+            url_fseek(pb, audio_size, SEEK_CUR);
         }
     }
 
     /* get video packet */
-    if ((ret = av_get_packet(pb, pkt, bink->remain_packet_size))
-                                   != bink->remain_packet_size)
+    if ((ret = av_get_packet(pb, pkt, bink->remain_packet_size)) < 0)
         return ret;
     pkt->stream_index = 0;
     pkt->pts = bink->video_pts++;
-    pkt->flags |= PKT_FLAG_KEY;
+    pkt->flags |= AV_PKT_FLAG_KEY;
 
     /* -1 instructs the next call to read_packet() to read the next frame */
     bink->current_track = -1;
@@ -241,6 +241,22 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     return 0;
 }
 
+static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
+{
+    BinkDemuxContext *bink = s->priv_data;
+    AVStream *vst = s->streams[0];
+
+    if (url_is_streamed(s->pb))
+        return -1;
+
+    /* seek to the first frame */
+    url_fseek(s->pb, vst->index_entries[0].pos, SEEK_SET);
+    bink->video_pts = 0;
+    memset(bink->audio_pts, 0, sizeof(bink->audio_pts));
+    bink->current_track = -1;
+    return 0;
+}
+
 AVInputFormat bink_demuxer = {
     "bink",
     NULL_IF_CONFIG_SMALL("Bink"),
@@ -248,4 +264,6 @@ AVInputFormat bink_demuxer = {
     probe,
     read_header,
     read_packet,
+    NULL,
+    read_seek,
 };