MediaProcessors
Functions
ffmpeg_video.c File Reference
#include "ffmpeg_video.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/mathematics.h>
#include <libavutil/opt.h>
#include <libswscale/swscale.h>
#include <libmediaprocsutils/log.h>
#include <libmediaprocsutils/stat_codes.h>
#include <libmediaprocsutils/check_utils.h>
#include <libmediaprocsutils/fair_lock.h>
#include <libmediaprocsutils/fifo.h>
#include <libmediaprocs/proc_if.h>
#include <libmediaprocs/proc.h>
#include "proc_frame_2_ffmpeg.h"
#include "video_settings.h"
Include dependency graph for ffmpeg_video.c:

Go to the source code of this file.

Functions

int ffmpeg_video_enc_ctx_init (ffmpeg_video_enc_ctx_t *ffmpeg_video_enc_ctx, int avcodecid, const video_settings_enc_ctx_t *video_settings_enc_ctx, log_ctx_t *log_ctx)
 
void ffmpeg_video_enc_ctx_deinit (ffmpeg_video_enc_ctx_t *ffmpeg_video_enc_ctx, log_ctx_t *log_ctx)
 
int ffmpeg_video_enc_frame (ffmpeg_video_enc_ctx_t *ffmpeg_video_enc_ctx, AVFrame *avframe_iput, fifo_ctx_t *oput_fifo_ctx, log_ctx_t *log_ctx)
 
int ffmpeg_video_dec_ctx_init (ffmpeg_video_dec_ctx_t *ffmpeg_video_dec_ctx, int avcodecid, const video_settings_dec_ctx_t *video_settings_dec_ctx, log_ctx_t *log_ctx)
 
void ffmpeg_video_dec_ctx_deinit (ffmpeg_video_dec_ctx_t *ffmpeg_video_dec_ctx, log_ctx_t *log_ctx)
 
int ffmpeg_video_dec_frame (ffmpeg_video_dec_ctx_t *ffmpeg_video_dec_ctx, AVPacket *avpacket_iput, fifo_ctx_t *oput_fifo_ctx, log_ctx_t *log_ctx)
 
void ffmpeg_video_reset_on_new_settings (proc_ctx_t *proc_ctx, volatile void *video_settings_opaque, int flag_is_encoder, log_ctx_t *log_ctx)
 

Detailed Description

Author
Rafael Antoniello

Definition in file ffmpeg_video.c.

Function Documentation

void ffmpeg_video_dec_ctx_deinit ( ffmpeg_video_dec_ctx_t ffmpeg_video_dec_ctx,
log_ctx_t log_ctx 
)

De-initialize FFmpeg's video decoding common context structure previously allocated by a call to 'ffmpeg_video_dec_ctx_init()'. This function release any heap-allocated field or structure member.

Parameters
ffmpeg_video_dec_ctxPointer to the video decoding common context structure to be de-initialized.
log_ctxExternally defined LOG module context structure.

Definition at line 403 of file ffmpeg_video.c.

int ffmpeg_video_dec_ctx_init ( ffmpeg_video_dec_ctx_t ffmpeg_video_dec_ctx,
int  avcodecid,
const video_settings_dec_ctx_t video_settings_dec_ctx,
log_ctx_t log_ctx 
)

Initialize FFmpeg's video decoding common context structure.

Parameters
ffmpeg_video_dec_ctxPointer to the video decoding common context structure to be initialized.
avcodecidUnambiguous decoder identifier (namely, the decoder type Id.).
video_settings_dec_ctxPointer to the initial generic video decoder settings context structure.
log_ctxExternally defined LOG module context structure.
Returns
Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).

Definition at line 348 of file ffmpeg_video.c.

int ffmpeg_video_dec_frame ( ffmpeg_video_dec_ctx_t ffmpeg_video_dec_ctx,
AVPacket *  avpacket_iput,
fifo_ctx_t oput_fifo_ctx,
log_ctx_t log_ctx 
)

Decode a complete video frame. If an output frame is produced, is written to the output FIFO buffer.

Parameters
ffmpeg_video_dec_ctxPointer to the video decoding common context structure.
avpacket_iputPointer to the (FFmpeg's) input packet structure.
oput_fifo_ctxPointer to the output FIFO buffer context structure.
log_ctxExternally defined LOG module context structure.
Returns
Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).

Definition at line 413 of file ffmpeg_video.c.

void ffmpeg_video_enc_ctx_deinit ( ffmpeg_video_enc_ctx_t ffmpeg_video_enc_ctx,
log_ctx_t log_ctx 
)

De-initialize FFmpeg's video encoding common context structure previously allocated by a call to 'ffmpeg_video_enc_ctx_init()'. This function release any heap-allocated field or structure member.

Parameters
ffmpeg_video_enc_ctxPointer to the video encoding common context structure to be de-initialized.
log_ctxExternally defined LOG module context structure.

Definition at line 163 of file ffmpeg_video.c.

int ffmpeg_video_enc_ctx_init ( ffmpeg_video_enc_ctx_t ffmpeg_video_enc_ctx,
int  avcodecid,
const video_settings_enc_ctx_t video_settings_enc_ctx,
log_ctx_t log_ctx 
)

Initialize FFmpeg's video encoding common context structure.

Parameters
ffmpeg_video_enc_ctxPointer to the video encoding common context structure to be initialized.
avcodecidUnambiguous encoder identifier (namely, the encoder type Id.).
video_settings_enc_ctxPointer to the initial generic video encoder settings context structure.
log_ctxExternally defined LOG module context structure.
Returns
Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).

Definition at line 53 of file ffmpeg_video.c.

int ffmpeg_video_enc_frame ( ffmpeg_video_enc_ctx_t ffmpeg_video_enc_ctx,
AVFrame *  avframe_iput,
fifo_ctx_t oput_fifo_ctx,
log_ctx_t log_ctx 
)

Encode a complete video frame. If an output frame is produced, is written to the output FIFO buffer.

Parameters
ffmpeg_video_enc_ctxPointer to the video encoding common context structure.
avframe_iputPointer to the (FFmpeg's) input frame structure.
oput_fifo_ctxPointer to the output FIFO buffer context structure.
log_ctxExternally defined LOG module context structure.
Returns
Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).

Definition at line 186 of file ffmpeg_video.c.

void ffmpeg_video_reset_on_new_settings ( proc_ctx_t proc_ctx,
volatile void *  video_settings_opaque,
int  flag_is_encoder,
log_ctx_t log_ctx 
)

FFmpeg video CODECS are not generally designed to accept changing settings on run-time. Thus, we have to reset (that is, de-initialize and re-initialize) the CODEC to set new settings while running the processor.

Parameters
proc_ctxPointer to the processor (PROC) context structure
video_settings_opaqueOpaque pointer to be casted either to an encoder or decoder video settings context structure.
flag_is_encoderSet to non-zero to signal that we are resetting an encoder, set to zero to identify a decoder.
log_ctxPointer to the LOG module context structure.

Definition at line 496 of file ffmpeg_video.c.