On Mon, 21 Apr 2008 14:02:09 -0400, Michael Niedermayer <[EMAIL PROTECTED]>  
wrote:
> On Thu, Apr 10, 2008 at 12:48:44AM -0400, Michael Conrad wrote:
...
>> I would really like to know why.  It seems to me that having a useful
>> pts in AVFrame is one of the most important things libavcodec could do
...
> Some codecs have pts stored in their bitstream, this ends up in  
> AVFrame.pts
> Some containers have pts stored in their bitstream, this ends up in
> AVPacket.pts
...
> If you want to reorder pts with frames that can easily be done by
> passing the pts over AVCodecContext.opaque and get_buffer()
...
>> If a codec decided to use reget_buffer instead of get_buffer it would
>> bypass the PTS-copy, and end up with a new frame with an old PTS value.
>
> And codecs using reget_buffer have dts==pts so there should be no need
> for any reordering.
...
>> * If the AVFrame->pts really isn't usable, could I just use the pts of
>>       the first packet which does *not* result in a completed frame as
>>       the pts of the next completed frame?
>
> no

Ah, thanks.  I think I'm getting the picture (please correct me if I'm  
wrong)

  * Both containers and streams can carry a PTS, but the containers are  
more reliable, and moreover, their PTS can be rescaled from one time_base  
to another to compare stream times.  So, use it, and ignore the other.

  * New codecs reorder their packets so that PTS==DTS, and the player  
doesn't need to reorder frames.  Older codec implementations might return  
packets in original stream order, and need sorted manually.  But, all  
codecs that do this also allocate buffers while decoding a packet with a  
relevant pts, so capturing the pts in the callback works.

As for the global problem, I see that the AVCodecContext also has an  
->opaque, so I can point that at my decoder thread's object, and not worry  
about decoder instances interfering with eachother.
        static int PTSCapture_FrameAlloc(AVCodecContext *c, AVFrame *pic) {
                TffmpegSource *This= (TffmpegSource*) c->opaque;
                int result= avcodec_default_get_buffer(c, pic);
                pic->opaque= new int64_t(This->CurVidPacketPTS);
                return result;
        }

> If you have suggestions and especially patches to improve anything they
> are welcome.

I think I might contribute some comment-pacthes to ffplay ;-) to help the  
next guy who comes along trying to figure out the details of stuff.

________
Michael Conrad
IntelliTree Solutions llc.
513-552-6362
[EMAIL PROTECTED]
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to