Go to the documentation of this file.
67 #if CONFIG_H264_MEDIACODEC_DECODER || CONFIG_HEVC_MEDIACODEC_DECODER
73 static const uint8_t nalu_header[] = { 0x00, 0x00, 0x00, 0x01 };
79 p =
av_malloc(
sizeof(nalu_header) + src_size);
85 *
out_size =
sizeof(nalu_header) + src_size;
87 memcpy(p, nalu_header,
sizeof(nalu_header));
88 memcpy(p +
sizeof(nalu_header),
src, src_size);
121 #if CONFIG_H264_MEDIACODEC_DECODER
131 int nal_length_size = 0;
133 memset(&ps, 0,
sizeof(ps));
136 &ps, &is_avc, &nal_length_size, 0, avctx);
158 if ((
ret = h2645_ps_to_nalu(
sps->data,
sps->data_size, &
data, &data_size)) < 0) {
164 if ((
ret = h2645_ps_to_nalu(
pps->data,
pps->data_size, &
data, &data_size)) < 0) {
181 #if CONFIG_HEVC_MEDIACODEC_DECODER
194 int nal_length_size = 0;
199 int vps_data_size = 0;
200 int sps_data_size = 0;
201 int pps_data_size = 0;
203 memset(&ps, 0,
sizeof(ps));
204 memset(&
sei, 0,
sizeof(
sei));
207 &ps, &
sei, &is_nalff, &nal_length_size, 0, 1, avctx);
236 if ((
ret = h2645_ps_to_nalu(
vps->data,
vps->data_size, &vps_data, &vps_data_size)) < 0 ||
237 (
ret = h2645_ps_to_nalu(
sps->data,
sps->data_size, &sps_data, &sps_data_size)) < 0 ||
238 (
ret = h2645_ps_to_nalu(
pps->data,
pps->data_size, &pps_data, &pps_data_size)) < 0) {
242 data_size = vps_data_size + sps_data_size + pps_data_size;
249 memcpy(
data , vps_data, vps_data_size);
250 memcpy(
data + vps_data_size , sps_data, sps_data_size);
251 memcpy(
data + vps_data_size + sps_data_size, pps_data, pps_data_size);
272 #if CONFIG_MPEG2_MEDIACODEC_DECODER || \
273 CONFIG_MPEG4_MEDIACODEC_DECODER || \
274 CONFIG_VP8_MEDIACODEC_DECODER || \
275 CONFIG_VP9_MEDIACODEC_DECODER
293 const char *codec_mime =
NULL;
306 #if CONFIG_H264_MEDIACODEC_DECODER
308 codec_mime =
"video/avc";
315 #if CONFIG_HEVC_MEDIACODEC_DECODER
317 codec_mime =
"video/hevc";
324 #if CONFIG_MPEG2_MEDIACODEC_DECODER
326 codec_mime =
"video/mpeg2";
328 ret = common_set_extradata(avctx,
format);
333 #if CONFIG_MPEG4_MEDIACODEC_DECODER
335 codec_mime =
"video/mp4v-es",
337 ret = common_set_extradata(avctx,
format);
342 #if CONFIG_VP8_MEDIACODEC_DECODER
344 codec_mime =
"video/x-vnd.on2.vp8";
346 ret = common_set_extradata(avctx,
format);
351 #if CONFIG_VP9_MEDIACODEC_DECODER
353 codec_mime =
"video/x-vnd.on2.vp9";
355 ret = common_set_extradata(avctx,
format);
375 s->ctx->delay_flush =
s->delay_flush;
383 "MediaCodec started successfully: codec = %s, ret = %d\n",
384 s->ctx->codec_name,
ret);
388 strcmp(
s->ctx->codec_name,
"OMX.amlogic.mpeg2.decoder.awesome") == 0) {
390 s->ctx->codec_name, sdk_int);
391 s->amlogic_mpeg2_api23_workaround = 1;
427 if (
s->ctx->current_input_buffer < 0) {
434 s->ctx->current_input_buffer =
index;
438 if (
s->buffered_pkt.size > 0) {
441 s->buffered_pkt.size -=
ret;
442 s->buffered_pkt.data +=
ret;
443 if (
s->buffered_pkt.size <= 0) {
447 "could not send entire packet in single input buffer (%d < %d)\n",
448 ret,
s->buffered_pkt.size+
ret);
454 if (
s->amlogic_mpeg2_api23_workaround &&
s->buffered_pkt.size <= 0) {
470 }
else if (
ret ==
AVERROR(EAGAIN) &&
s->ctx->current_input_buffer < 0) {
472 }
else if (
ret < 0) {
502 #define OFFSET(x) offsetof(MediaCodecH264DecContext, x)
503 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
505 {
"delay_flush",
"Delay flush until hw output buffers are returned to the decoder",
510 #define DECLARE_MEDIACODEC_VCLASS(short_name) \
511 static const AVClass ff_##short_name##_mediacodec_dec_class = { \
512 .class_name = #short_name "_mediacodec", \
513 .item_name = av_default_item_name, \
514 .option = ff_mediacodec_vdec_options, \
515 .version = LIBAVUTIL_VERSION_INT, \
518 #define DECLARE_MEDIACODEC_VDEC(short_name, full_name, codec_id, bsf) \
519 DECLARE_MEDIACODEC_VCLASS(short_name) \
520 AVCodec ff_##short_name##_mediacodec_decoder = { \
521 .name = #short_name "_mediacodec", \
522 .long_name = NULL_IF_CONFIG_SMALL(full_name " Android MediaCodec decoder"), \
523 .type = AVMEDIA_TYPE_VIDEO, \
525 .priv_class = &ff_##short_name##_mediacodec_dec_class, \
526 .priv_data_size = sizeof(MediaCodecH264DecContext), \
527 .init = mediacodec_decode_init, \
528 .receive_frame = mediacodec_receive_frame, \
529 .flush = mediacodec_decode_flush, \
530 .close = mediacodec_decode_close, \
531 .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \
532 .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, \
534 .hw_configs = mediacodec_hw_configs, \
535 .wrapper_name = "mediacodec", \
538 #if CONFIG_H264_MEDIACODEC_DECODER
542 #if CONFIG_HEVC_MEDIACODEC_DECODER
546 #if CONFIG_MPEG2_MEDIACODEC_DECODER
550 #if CONFIG_MPEG4_MEDIACODEC_DECODER
554 #if CONFIG_VP8_MEDIACODEC_DECODER
558 #if CONFIG_VP9_MEDIACODEC_DECODER
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void ff_h264_ps_uninit(H264ParamSets *ps)
Uninit H264 param sets structure.
#define AVERROR_EOF
End of file.
uint8_t * data
The data buffer.
This structure describes decoded (raw) audio or video data.
@ AV_HWDEVICE_TYPE_MEDIACODEC
int amlogic_mpeg2_api23_workaround
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps, int *is_avc, int *nal_length_size, int err_recognition, void *logctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
enum AVPixelFormat pix_fmt
For decoders, a hardware pixel format which that decoder may be able to decode to if suitable hardwar...
AVBufferRef * sps_list[MAX_SPS_COUNT]
@ AV_PIX_FMT_MEDIACODEC
hardware decoding through MediaCodec
Describe the class of an AVClass context structure.
void ff_hevc_ps_uninit(HEVCParamSets *ps)
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, HEVCSEI *sei, int *is_nalff, int *nal_length_size, int err_recognition, int apply_defdispwin, void *logctx)
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
AVBufferRef * pps_list[HEVC_MAX_PPS_COUNT]
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AV_LOG_INFO
Standard information.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
main external API structure.
AVBufferRef * pps_list[MAX_PPS_COUNT]
AVBufferRef * sps_list[HEVC_MAX_SPS_COUNT]
MediaCodecDecContext * ctx
@ AV_CODEC_HW_CONFIG_METHOD_AD_HOC
The codec supports this format by some ad-hoc method.
This structure stores compressed data.
int width
picture width / height.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVCodecHWConfig public
This is the structure which will be returned to the user by avcodec_get_hw_config().
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
AVBufferRef * vps_list[HEVC_MAX_VPS_COUNT]