[Libav-user] Copy Image Data from Decode Frame To Encode Frame

Paul B Mahol onemda at gmail.com
Sat Sep 14 21:15:19 CEST 2013


On 9/14/13, James Board <jpboard2 at yahoo.com> wrote:
> I'm writing a simple libAV program that reads an AVI file, decodes each
> frame, then writes that frame data to another AVI file as output.  The
> output
> file should be pretty much the same as the input file.
>
> I'm using the examples in the ffmpeg source as a start.  This is how
> each frame from the input file gets decoded.
>
>     avcodec_decode_video2(tmpCodecContextForInputFile, myFrameDecode,
> got_frame, &pktDecode);
>
> Then, in another subroutine, this is how each frame gets encoded for the
> output file:
>     avcodec_encode_video2(tmpCodecContextForOutputFile, &pktEncode,
> myFrameEncode, &got_packet);
>
> In between the two calls above, I have to convert the image data from
> myFrameDecode to image data in myFrameEncode.  That's what I'm having
> trouble
> with.  Right now I have lots of row/col loops and they do things differently
> for different pixel formats.  Is there a single subroutine I can that can
> convert the image data from myFrameDecode to the image data in
> myFrameEncode?

You can use same one if you enable reference counting, then you do not need to
copy it every time you need it. Just when going to modify it (if it is
referenced
by something else it will be copied otherwise reused....).

>
> Also, if the input and output file have the same pixel format, is there a
> simple way to copy the data from one to the other?
>
> Thanks
>


More information about the Libav-user mailing list