[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xine-cvslog
Subject:    [xine-cvs] HG: xine-lib: Generate video_step from stream and work
From:       Reinhard Nißl <rnissl () gmx ! de>
Date:       2007-10-23 22:16:18
Message-ID: f3b942ebf92bb1bacf34.1193171794 () hg ! debian ! org
[Download RAW message or body]

# HG changeset patch
# User Reinhard Nißl <rnissl@gmx.de>
# Date 1193171794 -7200
# Node ID f3b942ebf92bb1bacf340f24b953e8ef979571a7
# Parent  b46be46f55fef641d86f2a30681057b3cdc582f9
Generate video_step from stream and work around wrong field duration.
When demux_mpeg_pes uses FFmpeg for H.264 streams, it doesn't set
video_step as it doesn't know it. But FFmpeg provides it deriveable
from time_base. So let's use the derived value as long as it isn't
set explicitly.
Furthermore, demux_mpeg_pes set's BUF_FLAG_FRAME_END whenever it
encounters a H.264 access unit delimiter, which appears between
fields or frames, but it doesn't know, whether it deals with fields
or frames. avcodec_decode_video() on the other hand sets got_picture
even when the decoded data specifies just a field. But it also sets
the flag interlaced_frame. So let's use this flag to halve video_step
in order to show the decoded images just for a field duration.

diff -r f3b942ebf92bb1bacf340f24b953e8ef979571a7 -r \
                b46be46f55fef641d86f2a30681057b3cdc582f9 \
                src/libffmpeg/ff_video_decoder.c
--- a/src/libffmpeg/ff_video_decoder.c	Tue Oct 23 22:36:34 2007 +0200
+++ b/src/libffmpeg/ff_video_decoder.c	Sun Oct 21 19:12:32 2007 -0300
@@ -1156,6 +1156,7 @@ static void ff_handle_buffer (ff_video_d
     int         got_one_picture = 0;
     int         offset = 0;
     int         codec_type = buf->type & 0xFFFF0000;
+    int         video_step_to_use;
 
     /* pad input data */
     /* note: bitstream, alt bitstream reader or something will cause
@@ -1195,6 +1196,9 @@ static void ff_handle_buffer (ff_video_d
           }
         }
       }
+
+      /* use externally provided video_step or fall back to stream's time_base \
otherwise */ +      video_step_to_use = (this->video_step || \
!this->context->time_base.den) ? this->video_step : (int)(90000ll * \
this->context->time_base.num / this->context->time_base.den);  
       /* aspect ratio provided by ffmpeg, override previous setting */
       if ((this->aspect_ratio_prio < 2) &&
@@ -1285,16 +1289,20 @@ static void ff_handle_buffer (ff_video_d
         img->pts  = this->pts;
         this->pts = 0;
 
+        /* workaround for demux_mpeg_pes sending fields as frames */
+        if (!this->video_step && this->av_frame->interlaced_frame)
+          video_step_to_use /= 2;
+
         /* workaround for weird 120fps streams */
-        if( this->video_step == 750 ) {
+        if( video_step_to_use == 750 ) {
           /* fallback to the VIDEO_PTS_MODE */
-          this->video_step = 0;
+          video_step_to_use = 0;
         }
         
         if (this->av_frame->repeat_pict)
-          img->duration = this->video_step * 3 / 2;
+          img->duration = video_step_to_use * 3 / 2;
         else
-          img->duration = this->video_step;
+          img->duration = video_step_to_use;
 
         img->crop_right  = this->crop_right;
         img->crop_bottom = this->crop_bottom;
@@ -1318,7 +1326,7 @@ static void ff_handle_buffer (ff_video_d
       img->pts       = this->pts;
       this->pts      = 0;
 
-      img->duration  = this->video_step;
+      img->duration  = video_step_to_use;
       img->bad_frame = 1;
       this->skipframes = img->draw(img, this->stream);
       img->free(img);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Xine-cvslog mailing list
Xine-cvslog@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xine-cvslog


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic