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

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.

Oh, I think I see what you're saying. So, whatever packets happened to go into the decoder, at the time it finishes a frame, the frame may or may not be related to the packet times (depending on what frame ordering took place)? Is that right?

So I need to get the reordered_opaque value of the frame that got spat out.

Then, going back a step, I have to also set the reordered_opaque value of the frame when the buffer is obtained (since I intend to override get_buffer)? So, presumably, when a frame buffer is required, the codec's pts is the correct pts of the frame it's going to make?

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 did see that, but wasn't sure what was going on and why. I guess this system replaces the 'first packet's pts is the frame pts' logic used in the ffmpeg tutorial.






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