FFmpeg
Loading...
Searching...
No Matches
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/refstruct.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "hwconfig.h"
#include "ohcodec.h"
#include "pthread_internal.h"

Go to the source code of this file.

Data Structures

struct  OHCodecDecContext
 
struct  OHCodecBuffer
 

Macros

#define OFFSET(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

 DEFINE_OFFSET_ARRAY (OHCodecDecContext, mutex_cond, mutex_cond_cnt,(OFFSET(input_mutex), OFFSET(output_mutex)),(OFFSET(input_cond), OFFSET(output_cond)))
 
static void oh_decode_release (AVRefStructOpaque unused, void *obj)
 
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)
Value:

Definition at line 77 of file ohdec.c.

◆ VD

Definition at line 725 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, \
};
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
static const AVOption ohcodec_vdec_options[]
Definition ohdec.c:726
Describe the class of an AVClass context structure.
Definition log.h:76

Definition at line 734 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, \
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \
.bsfs = bsf, \
.hw_configs = oh_hw_configs, \
.p.wrapper_name = "ohcodec", \
};
#define FF_CODEC_RECEIVE_FRAME_CB(func)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition codec.h:126
#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:79
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition codec.h:133
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static av_cold int oh_decode_init(AVCodecContext *avctx)
Definition ohdec.c:372
static int oh_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Definition ohdec.c:636
#define DECLARE_OHCODEC_VCLASS(short_name)
Definition ohdec.c:734
static const AVCodecHWConfigInternal *const oh_hw_configs[]
Definition ohdec.c:712
static void oh_decode_flush(AVCodecContext *avctx)
Definition ohdec.c:694
static av_cold int oh_decode_close(AVCodecContext *avctx)
Definition ohdec.c:403
enum AVCodecID codec_id

Definition at line 742 of file ohdec.c.

Function Documentation

◆ DEFINE_OFFSET_ARRAY()

DEFINE_OFFSET_ARRAY ( OHCodecDecContext ,
mutex_cond ,
mutex_cond_cnt ,
(OFFSET(input_mutex), OFFSET(output_mutex)) ,
(OFFSET(input_cond), OFFSET(output_cond))  )

◆ oh_decode_release()

static void oh_decode_release ( AVRefStructOpaque unused,
void * obj )
static

Definition at line 88 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 99 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 144 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 219 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 298 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 317 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 336 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 372 of file ohdec.c.

◆ oh_decode_close()

static av_cold int oh_decode_close ( AVCodecContext * avctx)
static

Definition at line 403 of file ohdec.c.

◆ oh_buffer_release()

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

Definition at line 432 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 453 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 489 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 535 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 573 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 636 of file ohdec.c.

◆ oh_decode_flush()

static void oh_decode_flush ( AVCodecContext * avctx)
static

Definition at line 694 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,
},
}
#define NULL
Definition coverity.c:32
@ AV_CODEC_HW_CONFIG_METHOD_AD_HOC
The codec supports this format by some ad-hoc method.
Definition codec.h:311
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
Definition codec.h:282
@ AV_HWDEVICE_TYPE_OHCODEC
Definition hwcontext.h:43
@ AV_PIX_FMT_OHCODEC
Definition pixfmt.h:500

Definition at line 712 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}
}
#define VD
Definition amfdec.c:787
#define OFFSET(x)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ 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:275
const char * name
Definition qsvenc.c:142

Definition at line 726 of file ohdec.c.