On Nov 10, 2009, at 1:39 PM, Bruce Wheaton wrote:

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?

Huh, it's the same frame, but my opaque pointer was blanked, so my get_buffer callback didn't work properly (it has a pointer to the parent object that will make the actual storage).

Literally, between decode and get_buffer being called, the opaque gets zero'ed.

I tried setting the AVFrame type to user earlier, in the hopes that would persuade the codec to leave the data alone. I tried overriding reget_buffer.

So now I'm wondering, am I trying to do something evil, or possibly it's ffmpeg-mt that behaves differently? I think I'm using the opaque data exactly in the way intended, but is it not expected to persist across a get_buffer cycle?

Bruce




      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

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

Reply via email to