]> git.sesse.net Git - ffmpeg/commitdiff
add support for all framerates specified by the standard
authorJoakim Plate <elupus@ecce.se>
Sat, 28 Oct 2006 18:39:16 +0000 (18:39 +0000)
committerGuillaume Poirier <gpoirier@mplayerhq.hu>
Sat, 28 Oct 2006 18:39:16 +0000 (18:39 +0000)
Patch by Joakim elupus A ecce P se
Original thread:
Date: Oct 28, 2006 7:56 PM
Subject: [Ffmpeg-devel] [PATCH] Support for all official framerates in nsv demuxer

Originally committed as revision 6828 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/nsvdec.c

index b657f6747f85ad9774afbcf4b2d8b756de41b4a8..9a5fe97f898e99a17fc4106091565016ad76759d 100644 (file)
@@ -40,6 +40,8 @@
  * seems someone came to the same conclusions as me, and updated it:
  * (2) http://www.stud.ktu.lt/~vitslav/nsv/nsv-format.txt
  *     http://www.stud.ktu.lt/~vitslav/nsv/
+ * official docs
+ * (3) http://ultravox.aol.com/NSVFormat.rtf
  * Sample files:
  * (S1) http://www.nullsoft.com/nsv/samples/
  * http://www.nullsoft.com/nsv/samples/faster.nsv
@@ -208,15 +210,6 @@ static const CodecTag nsv_codec_audio_tags[] = {
     { 0, 0 },
 };
 
-static const AVRational nsv_framerate_table[] = {
-    {30,1},
-    {30000,1001},
-    {25,1},
-    {24000,1001},
-    {30,1},
-    {15000,1001},
-};
-
 //static int nsv_load_index(AVFormatContext *s);
 static int nsv_read_chunk(AVFormatContext *s, int fill_header);
 
@@ -415,11 +408,25 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
     vwidth = get_le16(pb);
     vheight = get_le16(pb);
     i = get_byte(pb);
-    /* XXX how big must the table be ? */
-    /* seems there is more to that... */
+
     PRINT(("NSV NSVs framerate code %2x\n", i));
-    if(i&0x80) framerate= nsv_framerate_table[i & 0x7F];
-    else       framerate= (AVRational){i, 1};
+    if(i&0x80) { /* odd way of giving native framerates from docs */
+        int t=(i & 0x7F)>>2;
+        if(t<16) framerate = (AVRational){1, t+1};
+        else     framerate = (AVRational){t-15, 1};
+
+        if(i&1){
+            framerate.num *= 1000;
+            framerate.den *= 1001;
+        }
+
+        if((i&3)==3)      framerate.num *= 24;
+        else if((i&3)==2) framerate.num *= 25;
+        else              framerate.num *= 30;
+    }
+    else
+        framerate= (AVRational){i, 1};
+
     nsv->avsync = get_le16(pb);
 #ifdef DEBUG
     print_tag("NSV NSVs vtag", vtag, 0);