]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/idroq.c
move time_base (pts_num/pts_den) from AVFormatContext -> AVStream
[ffmpeg] / libavformat / idroq.c
index c2af12f9182a8d3b9b1572f34f0cb377580c298f..bb074d55f14a67b6861eb52be7b96bd4bd8f26f0 100644 (file)
 
 #include "avformat.h"
 
-#define LE_16(x)  ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
-#define LE_32(x)  ((((uint8_t*)(x))[3] << 24) | \
-                   (((uint8_t*)(x))[2] << 16) | \
-                   (((uint8_t*)(x))[1] << 8) | \
-                    ((uint8_t*)(x))[0])
-
 #define RoQ_MAGIC_NUMBER 0x1084
 #define RoQ_CHUNK_PREAMBLE_SIZE 8
 #define RoQ_AUDIO_SAMPLE_RATE 22050
@@ -90,10 +84,6 @@ static int roq_read_header(AVFormatContext *s,
     roq->framerate = LE_16(&preamble[6]);
     roq->frame_pts_inc = 90000 / roq->framerate;
 
-    /* set the pts reference (1 pts = 1/90000) */
-    s->pts_num = 1;
-    s->pts_den = 90000;
-
     /* init private context parameters */
     roq->width = roq->height = roq->audio_channels = roq->video_pts = 
     roq->audio_frame_count = 0;
@@ -135,7 +125,7 @@ static int roq_read_header(AVFormatContext *s,
             break;
 
         default:
-            printf (" unknown RoQ chunk type (%04X)\n", LE_16(&preamble[0]));
+            av_log(s, AV_LOG_ERROR, " unknown RoQ chunk type (%04X)\n", LE_16(&preamble[0]));
             return AVERROR_INVALIDDATA;
             break;
         }
@@ -152,6 +142,8 @@ static int roq_read_header(AVFormatContext *s,
     st = av_new_stream(s, 0);
     if (!st)
         return AVERROR_NOMEM;
+    /* set the pts reference (1 pts = 1/90000) */
+    av_set_pts_info(st, 33, 1, 90000);
     roq->video_stream_index = st->index;
     st->codec.codec_type = CODEC_TYPE_VIDEO;
     st->codec.codec_id = CODEC_ID_ROQ;
@@ -163,6 +155,7 @@ static int roq_read_header(AVFormatContext *s,
         st = av_new_stream(s, 0);
         if (!st)
             return AVERROR_NOMEM;
+        av_set_pts_info(st, 33, 1, 90000);
         roq->audio_stream_index = st->index;
         st->codec.codec_type = CODEC_TYPE_AUDIO;
         st->codec.codec_id = CODEC_ID_ROQ_DPCM;
@@ -268,7 +261,7 @@ static int roq_read_packet(AVFormatContext *s,
             break;
 
         default:
-            printf ("  unknown RoQ chunk (%04X)\n", chunk_type);
+            av_log(s, AV_LOG_ERROR, "  unknown RoQ chunk (%04X)\n", chunk_type);
             return AVERROR_INVALIDDATA;
             break;
         }