FFmpeg
Loading...
Searching...
No Matches
mediacodecdec.c File Reference
#include "config_components.h"
#include <stdint.h>
#include <string.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/pixfmt.h"
#include "libavutil/internal.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "h264_parse.h"
#include "h264_ps.h"
#include "hevc/parse.h"
#include "hwconfig.h"
#include "internal.h"
#include "jni.h"
#include "mediacodec_wrapper.h"
#include "mediacodecdec_common.h"

Go to the source code of this file.

Data Structures

struct  MediaCodecContext
 

Macros

#define OFFSET(x)
 
#define VD   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 
#define DECLARE_MEDIACODEC_VCLASS(short_name)
 
#define DECLARE_MEDIACODEC_VDEC(short_name, full_name, codec_id, bsf)
 
#define AD   AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 
#define DECLARE_MEDIACODEC_ACLASS(short_name)
 
#define DECLARE_MEDIACODEC_ADEC(short_name, full_name, codec_id, bsf)
 

Functions

static av_cold int mediacodec_decode_close (AVCodecContext *avctx)
 
static av_cold int mediacodec_decode_init (AVCodecContext *avctx)
 
static int mediacodec_receive_frame (AVCodecContext *avctx, AVFrame *frame)
 
static void mediacodec_decode_flush (AVCodecContext *avctx)
 

Variables

static const AVCodecHWConfigInternal *const mediacodec_hw_configs []
 
static const AVOption ff_mediacodec_vdec_options []
 
static const AVOption ff_mediacodec_adec_options []
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 594 of file mediacodecdec.c.

◆ VD

Definition at line 595 of file mediacodecdec.c.

◆ DECLARE_MEDIACODEC_VCLASS

#define DECLARE_MEDIACODEC_VCLASS ( short_name)
Value:
static const AVClass ff_##short_name##_mediacodec_dec_class = { \
.class_name = #short_name "_mediacodec", \
.item_name = av_default_item_name, \
.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 ff_mediacodec_vdec_options[]
Describe the class of an AVClass context structure.
Definition log.h:76

Definition at line 606 of file mediacodecdec.c.

◆ DECLARE_MEDIACODEC_VDEC

#define DECLARE_MEDIACODEC_VDEC ( short_name,
full_name,
codec_id,
bsf )
Value:
const FFCodec ff_ ## short_name ## _mediacodec_decoder = { \
.p.name = #short_name "_mediacodec", \
CODEC_LONG_NAME(full_name " Android MediaCodec decoder"), \
.p.type = AVMEDIA_TYPE_VIDEO, \
.p.id = codec_id, \
.p.priv_class = &ff_##short_name##_mediacodec_dec_class, \
.priv_data_size = sizeof(MediaCodecContext), \
.bsfs = bsf, \
.hw_configs = mediacodec_hw_configs, \
.p.wrapper_name = "mediacodec", \
}; \
#define FF_CODEC_RECEIVE_FRAME_CB(func)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
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 const AVCodecHWConfigInternal *const mediacodec_hw_configs[]
static av_cold int mediacodec_decode_close(AVCodecContext *avctx)
#define DECLARE_MEDIACODEC_VCLASS(short_name)
static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
static void mediacodec_decode_flush(AVCodecContext *avctx)
static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
enum AVCodecID codec_id

Definition at line 614 of file mediacodecdec.c.

◆ AD

Definition at line 662 of file mediacodecdec.c.

◆ DECLARE_MEDIACODEC_ACLASS

#define DECLARE_MEDIACODEC_ACLASS ( short_name)
Value:
static const AVClass ff_##short_name##_mediacodec_dec_class = { \
.class_name = #short_name "_mediacodec", \
.item_name = av_default_item_name, \
.version = LIBAVUTIL_VERSION_INT, \
};
static const AVOption ff_mediacodec_adec_options[]

Definition at line 671 of file mediacodecdec.c.

◆ DECLARE_MEDIACODEC_ADEC

#define DECLARE_MEDIACODEC_ADEC ( short_name,
full_name,
codec_id,
bsf )
Value:
const FFCodec ff_ ## short_name ## _mediacodec_decoder = { \
.p.name = #short_name "_mediacodec", \
CODEC_LONG_NAME(full_name " Android MediaCodec decoder"), \
.p.type = AVMEDIA_TYPE_AUDIO, \
.p.id = codec_id, \
.p.priv_class = &ff_##short_name##_mediacodec_dec_class, \
.priv_data_size = sizeof(MediaCodecContext), \
.bsfs = bsf, \
.p.wrapper_name = "mediacodec", \
}; \
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
#define DECLARE_MEDIACODEC_ACLASS(short_name)

Definition at line 679 of file mediacodecdec.c.

Function Documentation

◆ mediacodec_decode_close()

static av_cold int mediacodec_decode_close ( AVCodecContext * avctx)
static

Definition at line 64 of file mediacodecdec.c.

Referenced by mediacodec_decode_init().

◆ mediacodec_decode_init()

static av_cold int mediacodec_decode_init ( AVCodecContext * avctx)
static

Definition at line 308 of file mediacodecdec.c.

◆ mediacodec_receive_frame()

static int mediacodec_receive_frame ( AVCodecContext * avctx,
AVFrame * frame )
static

Definition at line 489 of file mediacodecdec.c.

◆ mediacodec_decode_flush()

static void mediacodec_decode_flush ( AVCodecContext * avctx)
static

Definition at line 572 of file mediacodecdec.c.

Variable Documentation

◆ mediacodec_hw_configs

const AVCodecHWConfigInternal* const mediacodec_hw_configs[]
static
Initial value:
= {
.public = {
},
.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_MEDIACODEC
Definition hwcontext.h:38
@ AV_PIX_FMT_MEDIACODEC
hardware decoding through MediaCodec
Definition pixfmt.h:316

Definition at line 581 of file mediacodecdec.c.

◆ ff_mediacodec_vdec_options

const AVOption ff_mediacodec_vdec_options[]
static
Initial value:
= {
{ "delay_flush", "Delay flush until hw output buffers are returned to the decoder",
OFFSET(delay_flush), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VD },
{ "ndk_codec", "Use MediaCodec from NDK",
OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VD },
{ "operating_rate", "The desired operating rate that the codec will need to operate at, zero for unspecified",
OFFSET(operating_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VD },
{ NULL }
}
#define VD
Definition amfdec.c:787
#define OFFSET(x)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326

Definition at line 596 of file mediacodecdec.c.

◆ ff_mediacodec_adec_options

const AVOption ff_mediacodec_adec_options[]
static
Initial value:
= {
{ "ndk_codec", "Use MediaCodec from NDK",
OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, AD },
{ "operating_rate", "The desired operating rate that the codec will need to operate at, zero for unspecified",
OFFSET(operating_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AD },
{ NULL }
}
#define AD
Definition evrcdec.c:920

Definition at line 663 of file mediacodecdec.c.