FFMPEG: Explain parameters of any codecs function pointers

478 views Asked by At

I'm going through the article, How to integrate a codec in FFMPEG multimedia framework. According to it, every codec needs to have 3 basic functions to be defined and these functions are assigned to function pointers of the structure AVCodec.

The 3 function pointers specified in the above article are:

.init -> takes care of allocations and other initializations

.close -> freeing the allocated memory and de-initializations

.decode -> frame by frame decoding.

For the function pointer .decode, the function assigned is:

static int cook_decode_frame(AVCodecContext *avctx,
            void *data, int *data_size,
            uint8_t *buf, int buf_size) {
...

The details of these parameters are specified in the above article. However, in the latest code, when the same function is taken as an example, its declaration is as shown below:

static int cook_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame_ptr, AVPacket *avpkt)

I need to perform some mapping operations on the memory. So, i request if anyone could kindly explain the above parameters in the function declarations. Also, which parameter has the input buffer for decoding the frame? And after decoding a frame, to which parameter is the decoded frame mapped?

1

There are 1 answers

3
Dave On BEST ANSWER

From this source, it looks like the general idea is to decode audio/video frames from avpkt and put the output in data. Basically, the biggest change in API from your link is simply that buf and buf_size are rolled up into an AVPacket. And there's the got_frame_ptr as an indication of success.