[gst-devel] Re: gst-ffmpeg : waiting_for_key condition problem in dec (newsegement handling)

Antoine Tremblay hexa00 at gmail.com
Fri Dec 9 10:05:03 CET 2005


I've found out that this explains the problems stated in this post too :
http://sourceforge.net/mailarchive/message.php?msg_id=13760649

If anyone anyone has any input on this ?  it's apreciated :)

Thanks a lot

Antoine Tremblay



On 11/14/05, Antoine Tremblay <hexa00 at gmail.com> wrote:
>
> Hi all,
>
> I think there's a problem with the way the newsegment event in handled in
> gstffmpecdec.c
> in : gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event) (in HEAD)
>
> I see :   case GST_EVENT_NEWSEGMENT: { ....
>
>  if (ffmpegdec->opened) {
>         avcodec_flush_buffers (ffmpegdec->context);
>
>         if (ffmpegdec->context->codec_id == CODEC_ID_MPEG2VIDEO ||
>             ffmpegdec->context->codec_id == CODEC_ID_MPEG4 ||
>             ffmpegdec->context->codec_id == CODEC_ID_H264) {
>           ffmpegdec->waiting_for_key = TRUE;
>         }
>       }
>       ffmpegdec->waiting_for_key = TRUE;
>
> With this code waiting_for_key will always be set to TRUE ... so why is
> there the condition with the codecs_ids ? and why is it set to true  when
> it's most codecs don't require it ?  I guessed since these formats could be
> streamed the waiting_for_key should be false there and there should be an
> other conditions so that the second isn't executed...
>
> Or it's the opposite while it's not opened waiting_for_key should be false
> and then set true when opened for the selected codecs... That would be more
> logical and I think that's the way to do it but i'm just wondering why then
> would someone have placed MPEG4 and H264 there when they don't need a
> keyframe...?
>
> To me this should be written like :
>
>
> if (ffmpegdec->opened) {
>         avcodec_flush_buffers (ffmpegdec->context);
>
>         if (ffmpegdec->context->codec_id == CODEC_ID_MPEG2VIDEO || other
> coded which requires keyframes )
>          ffmpegdec->waiting_for_key = TRUE;
>         }
>         else {
>          ffmpegdec->waiting_for_key = FALSE;
>         }
> }
> else {
> ffmpegdec->waiting_for_key = FALSE;
> }
>
> Note that I realise this might be done so that when seeking you directly
> get a keyframe ,, but since newsegment is always sent before the 1st buffer
> is sent it has the effect that waiting_for_key is always set to TRUE at
> 1st .. so if you have a stream with 1 keyframe at start and then no other
> keyframes you will never be able to play it if you start at frame 2, even if
> you should be able to and do we really need to get a keyframe direclty ?
>
> Thanks a lot
>
> Antoine
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20051209/0f1c7914/attachment.htm>


More information about the gstreamer-devel mailing list