FFmpeg
Data Structures | Macros | Functions | Variables
ohdec.c File Reference
#include "config_components.h"
#include <stdbool.h>
#include <multimedia/player_framework/native_avcapability.h>
#include <multimedia/player_framework/native_avcodec_videodecoder.h>
#include "libavutil/fifo.h"
#include "libavutil/hwcontext_oh.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "hwconfig.h"
#include "ohcodec.h"

Go to the source code of this file.

Data Structures

struct  OHCodecDecContext
 
struct  OHCodecBuffer
 

Macros

#define OFFSET(x)   offsetof(OHCodecDecContext, x)
 
#define VD   (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM)
 
#define DECLARE_OHCODEC_VCLASS(short_name)
 
#define DECLARE_OHCODEC_VDEC(short_name, full_name, codec_id, bsf)
 

Functions

static void oh_decode_release (void *opaque, uint8_t *data)
 
static int oh_decode_create (OHCodecDecContext *s, AVCodecContext *avctx)
 
static int oh_decode_set_format (OHCodecDecContext *s, AVCodecContext *avctx)
 
static void oh_decode_on_err (OH_AVCodec *codec, int32_t err, void *userdata)
 
static void oh_decode_on_stream_changed (OH_AVCodec *codec, OH_AVFormat *format, void *userdata)
 
static void oh_decode_on_need_input (OH_AVCodec *codec, uint32_t index, OH_AVBuffer *buffer, void *userdata)
 
static void oh_decode_on_output (OH_AVCodec *codec, uint32_t index, OH_AVBuffer *buffer, void *userdata)
 
static int oh_decode_start (OHCodecDecContext *s, AVCodecContext *avctx)
 
static av_cold int oh_decode_init (AVCodecContext *avctx)
 
static av_cold int oh_decode_close (AVCodecContext *avctx)
 
static void oh_buffer_release (void *opaque, uint8_t *data)
 
static int oh_decode_wrap_hw_buffer (AVCodecContext *avctx, AVFrame *frame, OHBufferQueueItem *output, const OH_AVCodecBufferAttr *attr)
 
static int oh_decode_wrap_sw_buffer (AVCodecContext *avctx, AVFrame *frame, OHBufferQueueItem *output, const OH_AVCodecBufferAttr *attr)
 
static int oh_decode_output_frame (AVCodecContext *avctx, AVFrame *frame, OHBufferQueueItem *output)
 
static int oh_decode_send_pkt (AVCodecContext *avctx, OHBufferQueueItem *input)
 
static int oh_decode_receive_frame (AVCodecContext *avctx, AVFrame *frame)
 
static void oh_decode_flush (AVCodecContext *avctx)
 

Variables

static const AVCodecHWConfigInternal *const oh_hw_configs []
 
static const AVOption ohcodec_vdec_options []
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 726 of file ohdec.c.

◆ VD

Definition at line 727 of file ohdec.c.

◆ DECLARE_OHCODEC_VCLASS

#define DECLARE_OHCODEC_VCLASS (   short_name)
Value:
static const AVClass short_name##_oh_dec_class = { \
.class_name = #short_name "_ohcodec", \
.item_name = av_default_item_name, \
.option = ohcodec_vdec_options, \
.version = LIBAVUTIL_VERSION_INT, \
};

Definition at line 736 of file ohdec.c.

◆ DECLARE_OHCODEC_VDEC

#define DECLARE_OHCODEC_VDEC (   short_name,
  full_name,
  codec_id,
  bsf 
)
Value:
DECLARE_OHCODEC_VCLASS(short_name) \
const FFCodec ff_##short_name##_oh_decoder = { \
.p.name = #short_name "_ohcodec", \
CODEC_LONG_NAME(full_name " OpenHarmony Codec"), \
.p.type = AVMEDIA_TYPE_VIDEO, \
.p.id = codec_id, \
.p.priv_class = &short_name##_oh_dec_class, \
.priv_data_size = sizeof(OHCodecDecContext), \
.flush = oh_decode_flush, \
.close = oh_decode_close, \
AV_CODEC_CAP_HARDWARE, \
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \
.bsfs = bsf, \
.hw_configs = oh_hw_configs, \
.p.wrapper_name = "ohcodec", \
};

Definition at line 744 of file ohdec.c.

Function Documentation

◆ oh_decode_release()

static void oh_decode_release ( void *  opaque,
uint8_t *  data 
)
static

Definition at line 80 of file ohdec.c.

Referenced by oh_decode_create().

◆ oh_decode_create()

static int oh_decode_create ( OHCodecDecContext s,
AVCodecContext avctx 
)
static

Definition at line 91 of file ohdec.c.

Referenced by oh_decode_init().

◆ oh_decode_set_format()

static int oh_decode_set_format ( OHCodecDecContext s,
AVCodecContext avctx 
)
static

Definition at line 133 of file ohdec.c.

Referenced by oh_decode_init().

◆ oh_decode_on_err()

static void oh_decode_on_err ( OH_AVCodec *  codec,
int32_t  err,
void *  userdata 
)
static

◆ oh_decode_on_stream_changed()

static void oh_decode_on_stream_changed ( OH_AVCodec *  codec,
OH_AVFormat *  format,
void *  userdata 
)
static

Definition at line 208 of file ohdec.c.

Referenced by oh_decode_output_frame(), and oh_decode_start().

◆ oh_decode_on_need_input()

static void oh_decode_on_need_input ( OH_AVCodec *  codec,
uint32_t  index,
OH_AVBuffer *  buffer,
void *  userdata 
)
static

Definition at line 287 of file ohdec.c.

Referenced by oh_decode_start().

◆ oh_decode_on_output()

static void oh_decode_on_output ( OH_AVCodec *  codec,
uint32_t  index,
OH_AVBuffer *  buffer,
void *  userdata 
)
static

Definition at line 306 of file ohdec.c.

Referenced by oh_decode_start().

◆ oh_decode_start()

static int oh_decode_start ( OHCodecDecContext s,
AVCodecContext avctx 
)
static

Definition at line 325 of file ohdec.c.

Referenced by oh_decode_init().

◆ oh_decode_init()

static av_cold int oh_decode_init ( AVCodecContext avctx)
static

Definition at line 361 of file ohdec.c.

◆ oh_decode_close()

static av_cold int oh_decode_close ( AVCodecContext avctx)
static

Definition at line 393 of file ohdec.c.

◆ oh_buffer_release()

static void oh_buffer_release ( void *  opaque,
uint8_t *  data 
)
static

Definition at line 424 of file ohdec.c.

Referenced by oh_decode_wrap_hw_buffer().

◆ oh_decode_wrap_hw_buffer()

static int oh_decode_wrap_hw_buffer ( AVCodecContext avctx,
AVFrame frame,
OHBufferQueueItem output,
const OH_AVCodecBufferAttr *  attr 
)
static

Definition at line 450 of file ohdec.c.

Referenced by oh_decode_output_frame().

◆ oh_decode_wrap_sw_buffer()

static int oh_decode_wrap_sw_buffer ( AVCodecContext avctx,
AVFrame frame,
OHBufferQueueItem output,
const OH_AVCodecBufferAttr *  attr 
)
static

Definition at line 490 of file ohdec.c.

Referenced by oh_decode_output_frame().

◆ oh_decode_output_frame()

static int oh_decode_output_frame ( AVCodecContext avctx,
AVFrame frame,
OHBufferQueueItem output 
)
static

Definition at line 536 of file ohdec.c.

Referenced by oh_decode_receive_frame().

◆ oh_decode_send_pkt()

static int oh_decode_send_pkt ( AVCodecContext avctx,
OHBufferQueueItem input 
)
static

Definition at line 574 of file ohdec.c.

Referenced by oh_decode_receive_frame().

◆ oh_decode_receive_frame()

static int oh_decode_receive_frame ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 637 of file ohdec.c.

◆ oh_decode_flush()

static void oh_decode_flush ( AVCodecContext avctx)
static

Definition at line 695 of file ohdec.c.

Variable Documentation

◆ oh_hw_configs

const AVCodecHWConfigInternal* const oh_hw_configs[]
static
Initial value:
= {
.public = {
.pix_fmt = AV_PIX_FMT_OHCODEC,
.device_type = AV_HWDEVICE_TYPE_OHCODEC,
},
.hwaccel = NULL,
},
}

Definition at line 713 of file ohdec.c.

◆ ohcodec_vdec_options

const AVOption ohcodec_vdec_options[]
static
Initial value:
= {
{"codec_name", "Select codec by name",
{"allow_sw", "Allow software decoding",
OFFSET(allow_sw), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VD},
{NULL}
}

Definition at line 728 of file ohdec.c.

name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
DECLARE_OHCODEC_VCLASS
#define DECLARE_OHCODEC_VCLASS(short_name)
Definition: ohdec.c:736
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: codec_internal.h:42
oh_decode_receive_frame
static int oh_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Definition: ohdec.c:637
FFCodec
Definition: codec_internal.h:127
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
oh_decode_close
static av_cold int oh_decode_close(AVCodecContext *avctx)
Definition: ohdec.c:393
AV_CODEC_HW_CONFIG_METHOD_AD_HOC
@ AV_CODEC_HW_CONFIG_METHOD_AD_HOC
The codec supports this format by some ad-hoc method.
Definition: codec.h:327
codec_id
enum AVCodecID codec_id
Definition: vaapi_decode.c:410
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
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:240
AV_HWDEVICE_TYPE_OHCODEC
@ AV_HWDEVICE_TYPE_OHCODEC
Definition: hwcontext.h:43
OHCodecDecContext
Definition: ohdec.c:40
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
VD
#define VD
Definition: ohdec.c:727
oh_decode_init
static av_cold int oh_decode_init(AVCodecContext *avctx)
Definition: ohdec.c:361
AVCodecHWConfigInternal
Definition: hwconfig.h:25
oh_hw_configs
static const AVCodecHWConfigInternal *const oh_hw_configs[]
Definition: ohdec.c:713
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:81
ohcodec_vdec_options
static const AVOption ohcodec_vdec_options[]
Definition: ohdec.c:728
FF_CODEC_RECEIVE_FRAME_CB
#define FF_CODEC_RECEIVE_FRAME_CB(func)
Definition: codec_internal.h:349
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:76
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
Definition: codec.h:298
AV_PIX_FMT_OHCODEC
@ AV_PIX_FMT_OHCODEC
Definition: pixfmt.h:500
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
oh_decode_flush
static void oh_decode_flush(AVCodecContext *avctx)
Definition: ohdec.c:695
AV_CODEC_CAP_AVOID_PROBING
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: codec.h:123
OFFSET
#define OFFSET(x)
Definition: ohdec.c:726
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276