changeset 9059:3c5920f57063 libavcodec

Add ticks_per_frame, this should hopefully fix the regressions caused by the time_base change.
author michael
date Thu, 26 Feb 2009 23:47:32 +0000
parents 7c9368905639
children f49b1c1d2c16
files avcodec.h h264.c mpeg12.c options.c
diffstat 4 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/avcodec.h	Thu Feb 26 21:09:24 2009 +0000
+++ b/avcodec.h	Thu Feb 26 23:47:32 2009 +0000
@@ -30,7 +30,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 19
+#define LIBAVCODEC_VERSION_MINOR 20
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -2323,6 +2323,15 @@
      * - decoding: Set by libavcodec
      */
     struct AVHWAccel *hwaccel;
+
+    /**
+     * For some codecs, the time base is closer to the field rate than the frame rate.
+     * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
+     * if no telecine is used ...
+     *
+     * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
+     */
+    int ticks_per_frame;
 } AVCodecContext;
 
 /**
--- a/h264.c	Thu Feb 26 21:09:24 2009 +0000
+++ b/h264.c	Thu Feb 26 23:47:32 2009 +0000
@@ -2201,6 +2201,7 @@
     h->sei_dpb_output_delay = 0;
     h->sei_cpb_removal_delay = -1;
     h->sei_buffering_period_present = 0;
+    avctx->ticks_per_frame = 2;
     return 0;
 }
 
--- a/mpeg12.c	Thu Feb 26 21:09:24 2009 +0000
+++ b/mpeg12.c	Thu Feb 26 23:47:32 2009 +0000
@@ -1269,7 +1269,7 @@
             //MPEG-1 aspect
             avctx->sample_aspect_ratio= av_d2q(
                     1.0/ff_mpeg1_aspect[s->aspect_ratio_info], 255);
-
+            avctx->ticks_per_frame=1;
         }else{//MPEG-2
         //MPEG-2 fps
             av_reduce(
@@ -1278,6 +1278,7 @@
                 ff_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2,
                 ff_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
                 1<<30);
+            avctx->ticks_per_frame=2;
         //MPEG-2 aspect
             if(s->aspect_ratio_info > 1){
                 //we ignore the spec here as reality does not match the spec, see for example
--- a/options.c	Thu Feb 26 21:09:24 2009 +0000
+++ b/options.c	Thu Feb 26 23:47:32 2009 +0000
@@ -393,6 +393,7 @@
 {"request_channel_layout", NULL, OFFSET(request_channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|D, "request_channel_layout"},
 {"rc_max_vbv_use", NULL, OFFSET(rc_max_available_vbv_use), FF_OPT_TYPE_FLOAT, 1.0/3, 0.0, FLT_MAX, V|E},
 {"rc_min_vbv_use", NULL, OFFSET(rc_min_vbv_overflow_use),  FF_OPT_TYPE_FLOAT, 3,     0.0, FLT_MAX, V|E},
+{"ticks_per_frame", NULL, OFFSET(ticks_per_frame), FF_OPT_TYPE_INT, 1, 1, INT_MAX, A|V|E|D},
 {NULL},
 };