66 #if CONFIG_H264_MEDIACODEC_DECODER || CONFIG_HEVC_MEDIACODEC_DECODER 
   72     static const uint8_t nalu_header[] = { 0x00, 0x00, 0x00, 0x01 };
 
   74     if (!out || !out_size) {
 
   78     p = 
av_malloc(
sizeof(nalu_header) + src_size);
 
   84     *out_size = 
sizeof(nalu_header) + src_size;
 
   86     memcpy(p, nalu_header, 
sizeof(nalu_header));
 
   87     memcpy(p + 
sizeof(nalu_header), src, src_size);
 
   91         if (i < *out_size - 3 &&
 
  106             memmove(p + i + 1, p + i, *out_size - (i + 1));
 
  120 #if CONFIG_H264_MEDIACODEC_DECODER 
  130     int nal_length_size = 0;
 
  132     memset(&ps, 0, 
sizeof(ps));
 
  135                                    &ps, &is_avc, &nal_length_size, 0, avctx);
 
  157         if ((ret = h2645_ps_to_nalu(sps->
data, sps->
data_size, &data, &data_size)) < 0) {
 
  163         if ((ret = h2645_ps_to_nalu(pps->
data, pps->
data_size, &data, &data_size)) < 0) {
 
  180 #if CONFIG_HEVC_MEDIACODEC_DECODER 
  193     int nal_length_size = 0;
 
  198     int vps_data_size = 0;
 
  199     int sps_data_size = 0;
 
  200     int pps_data_size = 0;
 
  202     memset(&ps, 0, 
sizeof(ps));
 
  203     memset(&sei, 0, 
sizeof(sei));
 
  206                                    &ps, &sei, &is_nalff, &nal_length_size, 0, 1, avctx);
 
  231     if (vps && pps && sps) {
 
  235         if ((ret = h2645_ps_to_nalu(vps->
data, vps->
data_size, &vps_data, &vps_data_size)) < 0 ||
 
  236             (ret = h2645_ps_to_nalu(sps->
data, sps->
data_size, &sps_data, &sps_data_size)) < 0 ||
 
  237             (ret = h2645_ps_to_nalu(pps->
data, pps->
data_size, &pps_data, &pps_data_size)) < 0) {
 
  241         data_size = vps_data_size + sps_data_size + pps_data_size;
 
  248         memcpy(data                                , vps_data, vps_data_size);
 
  249         memcpy(data + vps_data_size                , sps_data, sps_data_size);
 
  250         memcpy(data + vps_data_size + sps_data_size, pps_data, pps_data_size);
 
  271 #if CONFIG_MPEG2_MEDIACODEC_DECODER || \ 
  272     CONFIG_MPEG4_MEDIACODEC_DECODER || \ 
  273     CONFIG_VP8_MEDIACODEC_DECODER   || \ 
  274     CONFIG_VP9_MEDIACODEC_DECODER 
  291     const char *codec_mime = 
NULL;
 
  304 #if CONFIG_H264_MEDIACODEC_DECODER 
  306         codec_mime = 
"video/avc";
 
  308         ret = h264_set_extradata(avctx, format);
 
  313 #if CONFIG_HEVC_MEDIACODEC_DECODER 
  315         codec_mime = 
"video/hevc";
 
  317         ret = hevc_set_extradata(avctx, format);
 
  322 #if CONFIG_MPEG2_MEDIACODEC_DECODER 
  324         codec_mime = 
"video/mpeg2";
 
  326         ret = common_set_extradata(avctx, format);
 
  331 #if CONFIG_MPEG4_MEDIACODEC_DECODER 
  333         codec_mime = 
"video/mp4v-es",
 
  335         ret = common_set_extradata(avctx, format);
 
  340 #if CONFIG_VP8_MEDIACODEC_DECODER 
  342         codec_mime = 
"video/x-vnd.on2.vp8";
 
  344         ret = common_set_extradata(avctx, format);
 
  349 #if CONFIG_VP9_MEDIACODEC_DECODER 
  351         codec_mime = 
"video/x-vnd.on2.vp9";
 
  353         ret = common_set_extradata(avctx, format);
 
  494 #define OFFSET(x) offsetof(MediaCodecH264DecContext, x) 
  495 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM 
  497     { 
"delay_flush", 
"Delay flush until hw output buffers are returned to the decoder",
 
  502 #define DECLARE_MEDIACODEC_VCLASS(short_name)                   \ 
  503 static const AVClass ff_##short_name##_mediacodec_dec_class = { \ 
  504     .class_name = #short_name "_mediacodec",                    \ 
  505     .item_name  = av_default_item_name,                         \ 
  506     .option     = ff_mediacodec_vdec_options,                   \ 
  507     .version    = LIBAVUTIL_VERSION_INT,                        \ 
  510 #define DECLARE_MEDIACODEC_VDEC(short_name, full_name, codec_id, bsf)                          \ 
  511 DECLARE_MEDIACODEC_VCLASS(short_name)                                                          \ 
  512 AVCodec ff_##short_name##_mediacodec_decoder = {                                               \ 
  513     .name           = #short_name "_mediacodec",                                               \ 
  514     .long_name      = NULL_IF_CONFIG_SMALL(full_name " Android MediaCodec decoder"),           \ 
  515     .type           = AVMEDIA_TYPE_VIDEO,                                                      \ 
  517     .priv_class     = &ff_##short_name##_mediacodec_dec_class,                                 \ 
  518     .priv_data_size = sizeof(MediaCodecH264DecContext),                                        \ 
  519     .init           = mediacodec_decode_init,                                                  \ 
  520     .receive_frame  = mediacodec_receive_frame,                                                \ 
  521     .flush          = mediacodec_decode_flush,                                                 \ 
  522     .close          = mediacodec_decode_close,                                                 \ 
  523     .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \ 
  524     .caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS,                                               \ 
  526     .hw_configs     = mediacodec_hw_configs,                                                   \ 
  527     .wrapper_name   = "mediacodec",                                                            \ 
  530 #if CONFIG_H264_MEDIACODEC_DECODER 
  534 #if CONFIG_HEVC_MEDIACODEC_DECODER 
  538 #if CONFIG_MPEG2_MEDIACODEC_DECODER 
  542 #if CONFIG_MPEG4_MEDIACODEC_DECODER 
  546 #if CONFIG_VP8_MEDIACODEC_DECODER 
  550 #if CONFIG_VP9_MEDIACODEC_DECODER 
AVCodecHWConfig public
This is the structure which will be returned to the user by avcodec_get_hw_config(). 
#define AVERROR_INVALIDDATA
Invalid data found when processing input. 
static const char * format[]
This structure describes decoded (raw) audio or video data. 
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory. 
AVBufferRef * vps_list[HEVC_MAX_VPS_COUNT]
ptrdiff_t const GLvoid * data
AVBufferRef * sps_list[MAX_SPS_COUNT]
MediaCodecDecContext * ctx
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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)
#define av_assert0(cond)
assert() equivalent, that is always enabled. 
AVBufferRef * sps_list[HEVC_MAX_SPS_COUNT]
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding. 
enum AVPixelFormat pix_fmt
A hardware pixel format which the codec can use. 
uint8_t * extradata
some codecs need / can use extradata like Huffman tables. 
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 AVERROR_EOF
End of file. 
AVBufferRef * pps_list[HEVC_MAX_PPS_COUNT]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
simple assert() macros that are a bit more flexible than ISO C assert(). 
The codec supports this format by some ad-hoc method. 
common internal API header 
int width
picture width / height. 
preferred ID for MPEG-1/2 video decoding 
void ff_hevc_ps_uninit(HEVCParamSets *ps)
#define AV_LOG_INFO
Standard information. 
Libavcodec external API header. 
AVBufferRef * pps_list[MAX_PPS_COUNT]
unsigned int sps_id
seq_parameter_set_id 
main external API structure. 
void av_packet_unref(AVPacket *pkt)
Wipe the packet. 
uint8_t * data
The data buffer. 
Describe the class of an AVClass context structure. 
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
hardware decoding through MediaCodec 
common internal api header. 
common internal and external API header 
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
void ff_h264_ps_uninit(H264ParamSets *ps)
Uninit H264 param sets structure. 
H.264 decoder/parser shared code. 
#define AVERROR_EXTERNAL
Generic error in an external library. 
The codec supports this format via the hw_device_ctx interface. 
This structure stores compressed data.