FFmpeg  4.3
Data Structures | Macros | Functions | Variables
omx.c File Reference
#include "config.h"
#include <dlfcn.h>
#include <OMX_Core.h>
#include <OMX_Component.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include "libavutil/avstring.h"
#include "libavutil/avutil.h"
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "h264.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  OMXContext
 
struct  OMXCodecContext
 

Macros

#define to_omx_ticks(x)   (x)
 
#define from_omx_ticks(x)   (x)
 
#define INIT_STRUCT(x)
 
#define CHECK(x)
 
#define OFFSET(x)   offsetof(OMXCodecContext, x)
 
#define VDE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static av_cold voiddlsym_prefixed (void *handle, const char *symbol, const char *prefix)
 
static av_cold int omx_try_load (OMXContext *s, void *logctx, const char *libname, const char *prefix, const char *libname2)
 
static av_cold OMXContextomx_init (void *logctx, const char *libname, const char *prefix)
 
static av_cold void omx_deinit (OMXContext *omx_context)
 
static void append_buffer (pthread_mutex_t *mutex, pthread_cond_t *cond, int *array_size, OMX_BUFFERHEADERTYPE **array, OMX_BUFFERHEADERTYPE *buffer)
 
static OMX_BUFFERHEADERTYPE * get_buffer (pthread_mutex_t *mutex, pthread_cond_t *cond, int *array_size, OMX_BUFFERHEADERTYPE **array, int wait)
 
static OMX_ERRORTYPE event_handler (OMX_HANDLETYPE component, OMX_PTR app_data, OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2, OMX_PTR event_data)
 
static OMX_ERRORTYPE empty_buffer_done (OMX_HANDLETYPE component, OMX_PTR app_data, OMX_BUFFERHEADERTYPE *buffer)
 
static OMX_ERRORTYPE fill_buffer_done (OMX_HANDLETYPE component, OMX_PTR app_data, OMX_BUFFERHEADERTYPE *buffer)
 
static av_cold int find_component (OMXContext *omx_context, void *logctx, const char *role, char *str, int str_size)
 
static av_cold int wait_for_state (OMXCodecContext *s, OMX_STATETYPE state)
 
static av_cold int omx_component_init (AVCodecContext *avctx, const char *role)
 
static av_cold void cleanup (OMXCodecContext *s)
 
static av_cold int omx_encode_init (AVCodecContext *avctx)
 
static int omx_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static av_cold int omx_encode_end (AVCodecContext *avctx)
 

Variables

static const OMX_CALLBACKTYPE callbacks
 
static const AVOption options []
 
static enum AVPixelFormat omx_encoder_pix_fmts []
 
static const AVClass omx_mpeg4enc_class
 
AVCodec ff_mpeg4_omx_encoder
 
static const AVClass omx_h264enc_class
 
AVCodec ff_h264_omx_encoder
 

Macro Definition Documentation

◆ to_omx_ticks

#define to_omx_ticks (   x)    (x)

Definition at line 60 of file omx.c.

◆ from_omx_ticks

#define from_omx_ticks (   x)    (x)

Definition at line 61 of file omx.c.

◆ INIT_STRUCT

#define INIT_STRUCT (   x)
Value:
do { \
x.nSize = sizeof(x); \
x.nVersion = s->version; \
} while (0)

Definition at line 64 of file omx.c.

◆ CHECK

#define CHECK (   x)
Value:
do { \
if (x != OMX_ErrorNone) { \
av_log(avctx, AV_LOG_ERROR, \
"err %x (%d) on line %d\n", x, x, __LINE__); \
return AVERROR_UNKNOWN; \
} \
} while (0)

Definition at line 68 of file omx.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(OMXCodecContext, x)

Definition at line 930 of file omx.c.

◆ VDE

Definition at line 931 of file omx.c.

◆ VE

Definition at line 932 of file omx.c.

Function Documentation

◆ dlsym_prefixed()

static av_cold void* dlsym_prefixed ( void handle,
const char *  symbol,
const char *  prefix 
)
static

Definition at line 89 of file omx.c.

Referenced by omx_try_load().

◆ omx_try_load()

static av_cold int omx_try_load ( OMXContext s,
void logctx,
const char *  libname,
const char *  prefix,
const char *  libname2 
)
static

Definition at line 96 of file omx.c.

Referenced by omx_init().

◆ omx_init()

static av_cold OMXContext* omx_init ( void logctx,
const char *  libname,
const char *  prefix 
)
static

Definition at line 140 of file omx.c.

Referenced by omx_encode_init().

◆ omx_deinit()

static av_cold void omx_deinit ( OMXContext omx_context)
static

Definition at line 180 of file omx.c.

Referenced by cleanup().

◆ append_buffer()

static void append_buffer ( pthread_mutex_t mutex,
pthread_cond_t cond,
int array_size,
OMX_BUFFERHEADERTYPE **  array,
OMX_BUFFERHEADERTYPE *  buffer 
)
static

Definition at line 232 of file omx.c.

Referenced by empty_buffer_done(), fill_buffer_done(), omx_encode_frame(), and omx_encode_init().

◆ get_buffer()

static OMX_BUFFERHEADERTYPE* get_buffer ( pthread_mutex_t mutex,
pthread_cond_t cond,
int array_size,
OMX_BUFFERHEADERTYPE **  array,
int  wait 
)
static

Definition at line 242 of file omx.c.

Referenced by cleanup(), omx_encode_frame(), and omx_encode_init().

◆ event_handler()

static OMX_ERRORTYPE event_handler ( OMX_HANDLETYPE  component,
OMX_PTR  app_data,
OMX_EVENTTYPE  event,
OMX_U32  data1,
OMX_U32  data2,
OMX_PTR  event_data 
)
static

Definition at line 263 of file omx.c.

◆ empty_buffer_done()

static OMX_ERRORTYPE empty_buffer_done ( OMX_HANDLETYPE  component,
OMX_PTR  app_data,
OMX_BUFFERHEADERTYPE *  buffer 
)
static

Definition at line 305 of file omx.c.

◆ fill_buffer_done()

static OMX_ERRORTYPE fill_buffer_done ( OMX_HANDLETYPE  component,
OMX_PTR  app_data,
OMX_BUFFERHEADERTYPE *  buffer 
)
static

Definition at line 323 of file omx.c.

◆ find_component()

static av_cold int find_component ( OMXContext omx_context,
void logctx,
const char *  role,
char *  str,
int  str_size 
)
static

Definition at line 338 of file omx.c.

Referenced by omx_encode_init().

◆ wait_for_state()

static av_cold int wait_for_state ( OMXCodecContext s,
OMX_STATETYPE  state 
)
static

Definition at line 375 of file omx.c.

Referenced by cleanup(), and omx_component_init().

◆ omx_component_init()

static av_cold int omx_component_init ( AVCodecContext avctx,
const char *  role 
)
static

Definition at line 387 of file omx.c.

Referenced by omx_encode_init().

◆ cleanup()

static av_cold void cleanup ( OMXCodecContext s)
static

Definition at line 590 of file omx.c.

Referenced by omx_encode_end().

◆ omx_encode_init()

static av_cold int omx_encode_init ( AVCodecContext avctx)
static

Definition at line 639 of file omx.c.

◆ omx_encode_frame()

static int omx_encode_frame ( AVCodecContext avctx,
AVPacket pkt,
const AVFrame frame,
int got_packet 
)
static

Definition at line 731 of file omx.c.

◆ omx_encode_end()

static av_cold int omx_encode_end ( AVCodecContext avctx)
static

Definition at line 922 of file omx.c.

Variable Documentation

◆ callbacks

const OMX_CALLBACKTYPE callbacks
static
Initial value:

Definition at line 332 of file omx.c.

Referenced by ff_ass_split_override_codes(), and omx_component_init().

◆ options

const AVOption options[]
static
Initial value:
= {
{ "omx_libname", "OpenMAX library name", OFFSET(libname), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VDE },
{ "omx_libprefix", "OpenMAX library prefix", OFFSET(libprefix), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VDE },
{ "zerocopy", "Try to avoid copying input frames if possible", OFFSET(input_zerocopy), AV_OPT_TYPE_INT, { .i64 = CONFIG_OMX_RPI }, 0, 1, VE },
{ "profile", "Set the encoding profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, FF_PROFILE_H264_HIGH, VE, "profile" },
{ "baseline", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_BASELINE }, 0, 0, VE, "profile" },
{ "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_MAIN }, 0, 0, VE, "profile" },
{ "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_HIGH }, 0, 0, VE, "profile" },
{ NULL }
}

Definition at line 933 of file omx.c.

◆ omx_encoder_pix_fmts

enum AVPixelFormat omx_encoder_pix_fmts[]
static
Initial value:

Definition at line 944 of file omx.c.

◆ omx_mpeg4enc_class

const AVClass omx_mpeg4enc_class
static
Initial value:
= {
.class_name = "mpeg4_omx",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 948 of file omx.c.

◆ ff_mpeg4_omx_encoder

AVCodec ff_mpeg4_omx_encoder
Initial value:
= {
.name = "mpeg4_omx",
.long_name = NULL_IF_CONFIG_SMALL("OpenMAX IL MPEG-4 video encoder"),
.priv_data_size = sizeof(OMXCodecContext),
.encode2 = omx_encode_frame,
.close = omx_encode_end,
.capabilities = AV_CODEC_CAP_DELAY,
.priv_class = &omx_mpeg4enc_class,
}

Definition at line 954 of file omx.c.

◆ omx_h264enc_class

const AVClass omx_h264enc_class
static
Initial value:
= {
.class_name = "h264_omx",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 969 of file omx.c.

◆ ff_h264_omx_encoder

AVCodec ff_h264_omx_encoder
Initial value:
= {
.name = "h264_omx",
.long_name = NULL_IF_CONFIG_SMALL("OpenMAX IL H.264 video encoder"),
.priv_data_size = sizeof(OMXCodecContext),
.encode2 = omx_encode_frame,
.close = omx_encode_end,
.capabilities = AV_CODEC_CAP_DELAY,
.priv_class = &omx_h264enc_class,
}

Definition at line 975 of file omx.c.

FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:40
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
FF_PROFILE_H264_BASELINE
#define FF_PROFILE_H264_BASELINE
Definition: avcodec.h:1898
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:61
profile
mfxU16 profile
Definition: qsvenc.c:45
OMXCodecContext
Definition: omx.c:189
empty_buffer_done
static OMX_ERRORTYPE empty_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data, OMX_BUFFERHEADERTYPE *buffer)
Definition: omx.c:305
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:71
x
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
Definition: fate.txt:150
omx_encoder_pix_fmts
static enum AVPixelFormat omx_encoder_pix_fmts[]
Definition: omx.c:944
FF_PROFILE_H264_HIGH
#define FF_PROFILE_H264_HIGH
Definition: avcodec.h:1902
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
s
#define s(width, name)
Definition: cbs_vp9.c:257
FF_PROFILE_UNKNOWN
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:1860
OFFSET
#define OFFSET(x)
Definition: omx.c:930
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:76
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
VDE
#define VDE
Definition: omx.c:931
event_handler
static OMX_ERRORTYPE event_handler(OMX_HANDLETYPE component, OMX_PTR app_data, OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2, OMX_PTR event_data)
Definition: omx.c:263
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:186
options
static const AVOption options[]
Definition: omx.c:933
omx_h264enc_class
static const AVClass omx_h264enc_class
Definition: omx.c:969
CONFIG_OMX_RPI
#define CONFIG_OMX_RPI
Definition: config.h:551
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
omx_encode_frame
static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: omx.c:731
omx_encode_init
static av_cold int omx_encode_init(AVCodecContext *avctx)
Definition: omx.c:639
omx_encode_end
static av_cold int omx_encode_end(AVCodecContext *avctx)
Definition: omx.c:922
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
omx_mpeg4enc_class
static const AVClass omx_mpeg4enc_class
Definition: omx.c:948
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:75
FF_PROFILE_H264_MAIN
#define FF_PROFILE_H264_MAIN
Definition: avcodec.h:1900
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:227
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232
VE
#define VE
Definition: omx.c:932
fill_buffer_done
static OMX_ERRORTYPE fill_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data, OMX_BUFFERHEADERTYPE *buffer)
Definition: omx.c:323