FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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

#define to_omx_ticks (   x)    (x)

Definition at line 60 of file omx.c.

Referenced by omx_encode_frame().

#define from_omx_ticks (   x)    (x)

Definition at line 61 of file omx.c.

Referenced by omx_encode_frame().

#define INIT_STRUCT (   x)
Value:
do { \
x.nSize = sizeof(x); \
x.nVersion = s->version; \
} while (0)
const char * s
Definition: avisynth_c.h:631

Definition at line 64 of file omx.c.

Referenced by omx_component_init().

#define CHECK (   x)
Value:
do { \
if (x != OMX_ErrorNone) { \
"err %x (%d) on line %d\n", x, x, __LINE__); \
} \
} while (0)
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
return
if(ret< 0)
Definition: vf_mcdeint.c:282
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:71

Definition at line 68 of file omx.c.

Referenced by omx_component_init().

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

Definition at line 877 of file omx.c.

Definition at line 878 of file omx.c.

Definition at line 879 of file omx.c.

Function Documentation

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().

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().

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().

static av_cold void omx_deinit ( OMXContext omx_context)
static

Definition at line 180 of file omx.c.

Referenced by cleanup().

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 231 of file omx.c.

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

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 241 of file omx.c.

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

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 262 of file omx.c.

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

Definition at line 304 of file omx.c.

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

Definition at line 322 of file omx.c.

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

Definition at line 337 of file omx.c.

Referenced by omx_encode_init().

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

Definition at line 374 of file omx.c.

Referenced by cleanup(), and omx_component_init().

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

Definition at line 386 of file omx.c.

Referenced by omx_encode_init().

static av_cold void cleanup ( OMXCodecContext s)
static

Definition at line 576 of file omx.c.

Referenced by omx_encode_end().

static av_cold int omx_encode_init ( AVCodecContext avctx)
static

Definition at line 625 of file omx.c.

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

Definition at line 721 of file omx.c.

static av_cold int omx_encode_end ( AVCodecContext avctx)
static

Definition at line 869 of file omx.c.

Variable Documentation

const OMX_CALLBACKTYPE callbacks
static
Initial value:
= {
}
static OMX_ERRORTYPE fill_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data, OMX_BUFFERHEADERTYPE *buffer)
Definition: omx.c:322
static OMX_ERRORTYPE empty_buffer_done(OMX_HANDLETYPE component, OMX_PTR app_data, OMX_BUFFERHEADERTYPE *buffer)
Definition: omx.c:304
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:262

Definition at line 331 of file omx.c.

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 = 0 }, 0, 1, VE },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define VE
Definition: omx.c:879
#define VDE
Definition: omx.c:878
#define OFFSET(x)
Definition: omx.c:877

Definition at line 880 of file omx.c.

enum AVPixelFormat omx_encoder_pix_fmts[]
static
Initial value:
= {
}
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62

Definition at line 887 of file omx.c.

const AVClass omx_mpeg4enc_class
static
Initial value:
= {
.class_name = "mpeg4_omx",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:70
av_default_item_name
static const AVOption options[]
Definition: omx.c:880

Definition at line 891 of file omx.c.

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,
}
#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
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int omx_encode_end(AVCodecContext *avctx)
Definition: omx.c:869
static enum AVPixelFormat omx_encoder_pix_fmts[]
Definition: omx.c:887
#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: avcodec.h:981
#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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: omx.c:721
static av_cold int omx_encode_init(AVCodecContext *avctx)
Definition: omx.c:625
static const AVClass omx_mpeg4enc_class
Definition: omx.c:891
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262

Definition at line 897 of file omx.c.

const AVClass omx_h264enc_class
static
Initial value:
= {
.class_name = "h264_omx",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:70
av_default_item_name
static const AVOption options[]
Definition: omx.c:880

Definition at line 912 of file omx.c.

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,
}
#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
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int omx_encode_end(AVCodecContext *avctx)
Definition: omx.c:869
static enum AVPixelFormat omx_encoder_pix_fmts[]
Definition: omx.c:887
#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: avcodec.h:981
#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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: omx.c:721
static av_cold int omx_encode_init(AVCodecContext *avctx)
Definition: omx.c:625
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
static const AVClass omx_h264enc_class
Definition: omx.c:912

Definition at line 918 of file omx.c.