On Oct 29, 2009, at 4:10 PM, Jean-Daniel Dupas wrote:


Le 29 oct. 2009 à 23:35, Bruce Wheaton a écrit :

What is reordered_opaque for? I presume it helps with reordered packets, and I see anecdotal evidence that if I want to override get_buffer, I should set the frame's reordered_opaque to the current codec pts, but I'm not sure if it's essential.

Currently, in my video decode tasks, I get the pts of the first video packet, and use that as the pts of the video frame I obtain (I stay in the decode job until I get a complete video frame). Is that no longer a valid approach?


It will not work with codec that use frame reordering (H.264 for example). To reorder the frame, the decoder will bufferize decoded frames, and so when you call decode_frame with such decoder, the decoded frame returned may not be the one corresponding to the packet you pass as argument.
In such cases, packet pts will not match frame pts.

Sorry, looks like I have another question. In this frame re-ordering, when I pass in an AVFrame, will I always get that same AVFrame out, or will the decode sometimes want to give me a new frame?

I'm trying to set the opaque pointer of the frame I get in, but when my decode routine finishes, I seem to get back another frame. Should I pass in NULL then, if I'm just going to get a new frame back?

Bruce





Have a look at ffplay.c to see how you can properly handle this kind of movies.

       is->video_st->codec->reordered_opaque= pkt->pts;
len1 = avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt);

if ((decoder_reorder_pts || pkt->dts == AV_NOPTS_VALUE) && frame->reordered_opaque != AV_NOPTS_VALUE)
           pts= frame->reordered_opaque;
       else if (pkt->dts != AV_NOPTS_VALUE)
           pts= pkt->dts;
       else
           pts= 0;
       pts *= av_q2d(is->video_st->time_base);

I just started to use the ffmpeg-mt branch, if that matters, and I did add:

        #ifdef AVCODEC_HAS_REORDERED_OPAQUE
                // take over pts for this frame to have it reordered
                pic->reordered_opaque        = c->reordered_opaque;
        #endif

To my buffer callback.

Regards,

Bruce Wheaton
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user


-- Jean-Daniel




_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to