Patchwork [04/14] vqa: set time base to frame rate as coded in the header.

login
register
mail settings
Submitter Justin Ruggles
Date Jan. 24, 2012, 4:57 p.m.
Message ID <1327424248-14025-5-git-send-email-justin.ruggles@gmail.com>
Download mbox | patch
Permalink /patch/15681/
State New
Headers show

Comments

Justin Ruggles - Jan. 24, 2012, 4:57 p.m.
According to Multimedia Wiki documentation, the frame rate is not always 15,
and the actual value can be found in the header.
---
 libavformat/westwood_vqa.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Kostya Shishkov - Jan. 24, 2012, 5:19 p.m.
On Tue, Jan 24, 2012 at 11:57:18AM -0500, Justin Ruggles wrote:
> According to Multimedia Wiki documentation, the frame rate is not always 15,
> and the actual value can be found in the header.
> ---
>  libavformat/westwood_vqa.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/westwood_vqa.c b/libavformat/westwood_vqa.c
> index 9a48263..9e5b211 100644
> --- a/libavformat/westwood_vqa.c
> +++ b/libavformat/westwood_vqa.c
> @@ -51,7 +51,6 @@
>  #define CMDS_TAG MKBETAG('C', 'M', 'D', 'S')
>  
>  #define VQA_HEADER_SIZE 0x2A
> -#define VQA_FRAMERATE 15
>  #define VQA_PREAMBLE_SIZE 8
>  
>  typedef struct WsVqaDemuxContext {
> @@ -93,7 +92,6 @@ static int wsvqa_read_header(AVFormatContext *s,
>      if (!st)
>          return AVERROR(ENOMEM);
>      st->start_time = 0;
> -    avpriv_set_pts_info(st, 33, 1, VQA_FRAMERATE);
>      wsvqa->video_stream_index = st->index;
>      st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
>      st->codec->codec_id = CODEC_ID_WS_VQA;
> @@ -113,6 +111,7 @@ static int wsvqa_read_header(AVFormatContext *s,
>      }
>      st->codec->width = AV_RL16(&header[6]);
>      st->codec->height = AV_RL16(&header[8]);
> +    avpriv_set_pts_info(st, 64, 1, header[12]);
>  
>      /* initialize the audio decoder stream for VQA v1 or nonzero samplerate */
>      if (AV_RL16(&header[24]) || (AV_RL16(&header[0]) == 1 && AV_RL16(&header[2]) == 1)) {
> -- 

I'd add a check for stupid FPS values (<1 and >30), otherwise OK

Patch

diff --git a/libavformat/westwood_vqa.c b/libavformat/westwood_vqa.c
index 9a48263..9e5b211 100644
--- a/libavformat/westwood_vqa.c
+++ b/libavformat/westwood_vqa.c
@@ -51,7 +51,6 @@ 
 #define CMDS_TAG MKBETAG('C', 'M', 'D', 'S')
 
 #define VQA_HEADER_SIZE 0x2A
-#define VQA_FRAMERATE 15
 #define VQA_PREAMBLE_SIZE 8
 
 typedef struct WsVqaDemuxContext {
@@ -93,7 +92,6 @@  static int wsvqa_read_header(AVFormatContext *s,
     if (!st)
         return AVERROR(ENOMEM);
     st->start_time = 0;
-    avpriv_set_pts_info(st, 33, 1, VQA_FRAMERATE);
     wsvqa->video_stream_index = st->index;
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codec->codec_id = CODEC_ID_WS_VQA;
@@ -113,6 +111,7 @@  static int wsvqa_read_header(AVFormatContext *s,
     }
     st->codec->width = AV_RL16(&header[6]);
     st->codec->height = AV_RL16(&header[8]);
+    avpriv_set_pts_info(st, 64, 1, header[12]);
 
     /* initialize the audio decoder stream for VQA v1 or nonzero samplerate */
     if (AV_RL16(&header[24]) || (AV_RL16(&header[0]) == 1 && AV_RL16(&header[2]) == 1)) {