]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/ffmdec.c
indent
[ffmpeg] / libavformat / ffmdec.c
index 02f4cdeece04f3b9be63df4282d993cf4dec9277..9c0ea89eb48b3c479b444a967f4e3a7f9a144d2c 100644 (file)
@@ -79,7 +79,7 @@ static int ffm_is_avail_data(AVFormatContext *s, int size)
 
 /* first is true if we read the frame header */
 static int ffm_read_data(AVFormatContext *s,
-                         uint8_t *buf, int size, int first)
+                         uint8_t *buf, int size, int header)
 {
     FFMContext *ffm = s->priv_data;
     ByteIOContext *pb = s->pb;
@@ -119,10 +119,10 @@ static int ffm_read_data(AVFormatContext *s,
                     return 0;
                 }
                 ffm->first_packet = 0;
-                if ((frame_offset & 0x7ffff) < FFM_HEADER_SIZE)
+                if ((frame_offset & 0x7fff) < FFM_HEADER_SIZE)
                     return -1;
                 ffm->packet_ptr = ffm->packet + (frame_offset & 0x7fff) - FFM_HEADER_SIZE;
-                if (!first)
+                if (!header)
                     break;
             } else {
                 ffm->packet_ptr = ffm->packet;
@@ -133,7 +133,7 @@ static int ffm_read_data(AVFormatContext *s,
         buf += len;
         ffm->packet_ptr += len;
         size -= len;
-        first = 0;
+        header = 0;
     }
     return size1 - size;
 }
@@ -152,7 +152,7 @@ static void ffm_seek1(AVFormatContext *s, offset_t pos1)
     if (pos >= ffm->file_size)
         pos -= (ffm->file_size - FFM_PACKET_SIZE);
 #ifdef DEBUG_SEEK
-    printf("seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
+    av_log(s, AV_LOG_DEBUG, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
 #endif
     url_fseek(pb, pos, SEEK_SET);
 }
@@ -166,7 +166,7 @@ static int64_t get_pts(AVFormatContext *s, offset_t pos)
     url_fskip(pb, 4);
     pts = get_be64(pb);
 #ifdef DEBUG_SEEK
-    printf("pts=%0.6f\n", pts / 1000000.0);
+    av_log(s, AV_LOG_DEBUG, "pts=%0.6f\n", pts / 1000000.0);
 #endif
     return pts;
 }
@@ -232,7 +232,6 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
 {
     FFMContext *ffm = s->priv_data;
     AVStream *st;
-    FFMStream *fst;
     ByteIOContext *pb = s->pb;
     AVCodecContext *codec;
     int i, nb_streams;
@@ -263,15 +262,10 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
         st = av_new_stream(s, 0);
         if (!st)
             goto fail;
-        fst = av_mallocz(sizeof(FFMStream));
-        if (!fst)
-            goto fail;
         s->streams[i] = st;
 
         av_set_pts_info(st, 64, 1, 1000000);
 
-        st->priv_data = fst;
-
         codec = st->codec;
         /* generic info */
         codec->codec_id = get_be32(pb);
@@ -370,12 +364,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
             FRAME_HEADER_SIZE)
             return AVERROR(EAGAIN);
 #if 0
-        {
-            int i;
-            for(i=0;i<FRAME_HEADER_SIZE;i++)
-                printf("%02x ", ffm->header[i]);
-            printf("\n");
-        }
+        av_hexdump_log(s, AV_LOG_DEBUG, ffm->header, FRAME_HEADER_SIZE);
 #endif
         ffm->read_state = READ_DATA;
         /* fall thru */
@@ -427,7 +416,7 @@ static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, in
     double pos1;
 
 #ifdef DEBUG_SEEK
-    printf("wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
+    av_log(s, AV_LOG_DEBUG, "wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
 #endif
     /* find the position using linear interpolation (better than
        dichotomy in typical cases) */
@@ -459,6 +448,13 @@ static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, in
         pos -= FFM_PACKET_SIZE;
  found:
     ffm_seek1(s, pos);
+
+    /* reset read state */
+    ffm->read_state = READ_HEADER;
+    ffm->packet_ptr = ffm->packet;
+    ffm->packet_end = ffm->packet;
+    ffm->first_packet = 1;
+
     return 0;
 }
 
@@ -485,7 +481,7 @@ static int ffm_probe(AVProbeData *p)
 
 AVInputFormat ffm_demuxer = {
     "ffm",
-    "ffm format",
+    NULL_IF_CONFIG_SMALL("ffm format"),
     sizeof(FFMContext),
     ffm_probe,
     ffm_read_header,