FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mediacodecdec.c
Go to the documentation of this file.
1 /*
2  * Android MediaCodec MPEG-2 / H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
3  *
4  * Copyright (c) 2015-2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include <stdint.h>
24 #include <string.h>
25 
26 #include "libavutil/avassert.h"
27 #include "libavutil/common.h"
28 #include "libavutil/opt.h"
29 #include "libavutil/intreadwrite.h"
30 #include "libavutil/pixfmt.h"
31 
32 #include "avcodec.h"
33 #include "decode.h"
34 #include "h264_parse.h"
35 #include "hevc_parse.h"
36 #include "hwaccel.h"
37 #include "internal.h"
38 #include "mediacodec_wrapper.h"
39 #include "mediacodecdec_common.h"
40 
41 typedef struct MediaCodecH264DecContext {
42 
44 
46 
48 
50 {
52 
53  ff_mediacodec_dec_close(avctx, s->ctx);
54  s->ctx = NULL;
55 
57 
58  return 0;
59 }
60 
61 #if CONFIG_H264_MEDIACODEC_DECODER || CONFIG_HEVC_MEDIACODEC_DECODER
62 static int h2645_ps_to_nalu(const uint8_t *src, int src_size, uint8_t **out, int *out_size)
63 {
64  int i;
65  int ret = 0;
66  uint8_t *p = NULL;
67  static const uint8_t nalu_header[] = { 0x00, 0x00, 0x00, 0x01 };
68 
69  if (!out || !out_size) {
70  return AVERROR(EINVAL);
71  }
72 
73  p = av_malloc(sizeof(nalu_header) + src_size);
74  if (!p) {
75  return AVERROR(ENOMEM);
76  }
77 
78  *out = p;
79  *out_size = sizeof(nalu_header) + src_size;
80 
81  memcpy(p, nalu_header, sizeof(nalu_header));
82  memcpy(p + sizeof(nalu_header), src, src_size);
83 
84  /* Escape 0x00, 0x00, 0x0{0-3} pattern */
85  for (i = 4; i < *out_size; i++) {
86  if (i < *out_size - 3 &&
87  p[i + 0] == 0 &&
88  p[i + 1] == 0 &&
89  p[i + 2] <= 3) {
90  uint8_t *new;
91 
92  *out_size += 1;
93  new = av_realloc(*out, *out_size);
94  if (!new) {
95  ret = AVERROR(ENOMEM);
96  goto done;
97  }
98  *out = p = new;
99 
100  i = i + 2;
101  memmove(p + i + 1, p + i, *out_size - (i + 1));
102  p[i] = 0x03;
103  }
104  }
105 done:
106  if (ret < 0) {
107  av_freep(out);
108  *out_size = 0;
109  }
110 
111  return ret;
112 }
113 #endif
114 
115 #if CONFIG_H264_MEDIACODEC_DECODER
116 static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
117 {
118  int i;
119  int ret;
120 
121  H264ParamSets ps;
122  const PPS *pps = NULL;
123  const SPS *sps = NULL;
124  int is_avc = 0;
125  int nal_length_size = 0;
126 
127  memset(&ps, 0, sizeof(ps));
128 
130  &ps, &is_avc, &nal_length_size, 0, avctx);
131  if (ret < 0) {
132  goto done;
133  }
134 
135  for (i = 0; i < MAX_PPS_COUNT; i++) {
136  if (ps.pps_list[i]) {
137  pps = (const PPS*)ps.pps_list[i]->data;
138  break;
139  }
140  }
141 
142  if (pps) {
143  if (ps.sps_list[pps->sps_id]) {
144  sps = (const SPS*)ps.sps_list[pps->sps_id]->data;
145  }
146  }
147 
148  if (pps && sps) {
149  uint8_t *data = NULL;
150  int data_size = 0;
151 
152  if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
153  goto done;
154  }
155  ff_AMediaFormat_setBuffer(format, "csd-0", (void*)data, data_size);
156  av_freep(&data);
157 
158  if ((ret = h2645_ps_to_nalu(pps->data, pps->data_size, &data, &data_size)) < 0) {
159  goto done;
160  }
161  ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, data_size);
162  av_freep(&data);
163  } else {
164  av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from extradata");
165  ret = AVERROR_INVALIDDATA;
166  }
167 
168 done:
169  ff_h264_ps_uninit(&ps);
170 
171  return ret;
172 }
173 #endif
174 
175 #if CONFIG_HEVC_MEDIACODEC_DECODER
176 static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
177 {
178  int i;
179  int ret;
180 
181  HEVCParamSets ps;
182  HEVCSEI sei;
183 
184  const HEVCVPS *vps = NULL;
185  const HEVCPPS *pps = NULL;
186  const HEVCSPS *sps = NULL;
187  int is_nalff = 0;
188  int nal_length_size = 0;
189 
190  uint8_t *vps_data = NULL;
191  uint8_t *sps_data = NULL;
192  uint8_t *pps_data = NULL;
193  int vps_data_size = 0;
194  int sps_data_size = 0;
195  int pps_data_size = 0;
196 
197  memset(&ps, 0, sizeof(ps));
198  memset(&sei, 0, sizeof(sei));
199 
201  &ps, &sei, &is_nalff, &nal_length_size, 0, 1, avctx);
202  if (ret < 0) {
203  goto done;
204  }
205 
206  for (i = 0; i < HEVC_MAX_VPS_COUNT; i++) {
207  if (ps.vps_list[i]) {
208  vps = (const HEVCVPS*)ps.vps_list[i]->data;
209  break;
210  }
211  }
212 
213  for (i = 0; i < HEVC_MAX_PPS_COUNT; i++) {
214  if (ps.pps_list[i]) {
215  pps = (const HEVCPPS*)ps.pps_list[i]->data;
216  break;
217  }
218  }
219 
220  if (pps) {
221  if (ps.sps_list[pps->sps_id]) {
222  sps = (const HEVCSPS*)ps.sps_list[pps->sps_id]->data;
223  }
224  }
225 
226  if (vps && pps && sps) {
227  uint8_t *data;
228  int data_size;
229 
230  if ((ret = h2645_ps_to_nalu(vps->data, vps->data_size, &vps_data, &vps_data_size)) < 0 ||
231  (ret = h2645_ps_to_nalu(sps->data, sps->data_size, &sps_data, &sps_data_size)) < 0 ||
232  (ret = h2645_ps_to_nalu(pps->data, pps->data_size, &pps_data, &pps_data_size)) < 0) {
233  goto done;
234  }
235 
236  data_size = vps_data_size + sps_data_size + pps_data_size;
237  data = av_mallocz(data_size);
238  if (!data) {
239  ret = AVERROR(ENOMEM);
240  goto done;
241  }
242 
243  memcpy(data , vps_data, vps_data_size);
244  memcpy(data + vps_data_size , sps_data, sps_data_size);
245  memcpy(data + vps_data_size + sps_data_size, pps_data, pps_data_size);
246 
247  ff_AMediaFormat_setBuffer(format, "csd-0", data, data_size);
248 
249  av_freep(&data);
250  } else {
251  av_log(avctx, AV_LOG_ERROR, "Could not extract VPS/PPS/SPS from extradata");
252  ret = AVERROR_INVALIDDATA;
253  }
254 
255 done:
256  ff_hevc_ps_uninit(&ps);
257 
258  av_freep(&vps_data);
259  av_freep(&sps_data);
260  av_freep(&pps_data);
261 
262  return ret;
263 }
264 #endif
265 
266 #if CONFIG_MPEG2_MEDIACODEC_DECODER
267 static int mpeg2_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
268 {
269  int ret = 0;
270 
271  if (avctx->extradata) {
272  ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
273  }
274 
275  return ret;
276 }
277 #endif
278 
279 #if CONFIG_MPEG4_MEDIACODEC_DECODER
280 static int mpeg4_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
281 {
282  int ret = 0;
283 
284  if (avctx->extradata) {
285  ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
286  }
287 
288  return ret;
289 }
290 #endif
291 
292 #if CONFIG_VP8_MEDIACODEC_DECODER || CONFIG_VP9_MEDIACODEC_DECODER
293 static int vpx_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
294 {
295  int ret = 0;
296 
297  if (avctx->extradata) {
298  ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
299  }
300 
301  return ret;
302 }
303 #endif
304 
306 {
307  int ret;
308 
309  const char *codec_mime = NULL;
310 
311  FFAMediaFormat *format = NULL;
313 
314  format = ff_AMediaFormat_new();
315  if (!format) {
316  av_log(avctx, AV_LOG_ERROR, "Failed to create media format\n");
317  ret = AVERROR_EXTERNAL;
318  goto done;
319  }
320 
321  switch (avctx->codec_id) {
322 #if CONFIG_H264_MEDIACODEC_DECODER
323  case AV_CODEC_ID_H264:
324  codec_mime = "video/avc";
325 
326  ret = h264_set_extradata(avctx, format);
327  if (ret < 0)
328  goto done;
329  break;
330 #endif
331 #if CONFIG_HEVC_MEDIACODEC_DECODER
332  case AV_CODEC_ID_HEVC:
333  codec_mime = "video/hevc";
334 
335  ret = hevc_set_extradata(avctx, format);
336  if (ret < 0)
337  goto done;
338  break;
339 #endif
340 #if CONFIG_MPEG2_MEDIACODEC_DECODER
342  codec_mime = "video/mpeg2";
343 
344  ret = mpeg2_set_extradata(avctx, format);
345  if (ret < 0)
346  goto done;
347  break;
348 #endif
349 #if CONFIG_MPEG4_MEDIACODEC_DECODER
350  case AV_CODEC_ID_MPEG4:
351  codec_mime = "video/mp4v-es",
352 
353  ret = mpeg4_set_extradata(avctx, format);
354  if (ret < 0)
355  goto done;
356  break;
357 #endif
358 #if CONFIG_VP8_MEDIACODEC_DECODER
359  case AV_CODEC_ID_VP8:
360  codec_mime = "video/x-vnd.on2.vp8";
361 
362  ret = vpx_set_extradata(avctx, format);
363  if (ret < 0)
364  goto done;
365  break;
366 #endif
367 #if CONFIG_VP9_MEDIACODEC_DECODER
368  case AV_CODEC_ID_VP9:
369  codec_mime = "video/x-vnd.on2.vp9";
370 
371  ret = vpx_set_extradata(avctx, format);
372  if (ret < 0)
373  goto done;
374  break;
375 #endif
376  default:
377  av_assert0(0);
378  }
379 
380  ff_AMediaFormat_setString(format, "mime", codec_mime);
381  ff_AMediaFormat_setInt32(format, "width", avctx->width);
382  ff_AMediaFormat_setInt32(format, "height", avctx->height);
383 
384  s->ctx = av_mallocz(sizeof(*s->ctx));
385  if (!s->ctx) {
386  av_log(avctx, AV_LOG_ERROR, "Failed to allocate MediaCodecDecContext\n");
387  ret = AVERROR(ENOMEM);
388  goto done;
389  }
390 
391  if ((ret = ff_mediacodec_dec_init(avctx, s->ctx, codec_mime, format)) < 0) {
392  s->ctx = NULL;
393  goto done;
394  }
395 
396  av_log(avctx, AV_LOG_INFO, "MediaCodec started successfully, ret = %d\n", ret);
397 
398 done:
399  if (format) {
400  ff_AMediaFormat_delete(format);
401  }
402 
403  if (ret < 0) {
405  }
406 
407  return ret;
408 }
409 
412  AVFrame *frame, bool wait)
413 {
414  int ret;
415 
416  /* send any pending data from buffered packet */
417  while (s->buffered_pkt.size) {
418  ret = ff_mediacodec_dec_send(avctx, s->ctx, &s->buffered_pkt);
419  if (ret == AVERROR(EAGAIN))
420  break;
421  else if (ret < 0)
422  return ret;
423  s->buffered_pkt.size -= ret;
424  s->buffered_pkt.data += ret;
425  if (s->buffered_pkt.size <= 0)
427  }
428 
429  /* check for new frame */
430  return ff_mediacodec_dec_receive(avctx, s->ctx, frame, wait);
431 }
432 
434 {
436  int ret;
437 
438  /*
439  * MediaCodec.flush() discards both input and output buffers, thus we
440  * need to delay the call to this function until the user has released or
441  * renderered the frames he retains.
442  *
443  * After we have buffered an input packet, check if the codec is in the
444  * flushing state. If it is, we need to call ff_mediacodec_dec_flush.
445  *
446  * ff_mediacodec_dec_flush returns 0 if the flush cannot be performed on
447  * the codec (because the user retains frames). The codec stays in the
448  * flushing state.
449  *
450  * ff_mediacodec_dec_flush returns 1 if the flush can actually be
451  * performed on the codec. The codec leaves the flushing state and can
452  * process again packets.
453  *
454  * ff_mediacodec_dec_flush returns a negative value if an error has
455  * occurred.
456  *
457  */
458  if (ff_mediacodec_dec_is_flushing(avctx, s->ctx)) {
459  if (!ff_mediacodec_dec_flush(avctx, s->ctx)) {
460  return AVERROR(EAGAIN);
461  }
462  }
463 
464  /* flush buffered packet and check for new frame */
465  ret = mediacodec_send_receive(avctx, s, frame, false);
466  if (ret != AVERROR(EAGAIN))
467  return ret;
468 
469  /* skip fetching new packet if we still have one buffered */
470  if (s->buffered_pkt.size > 0)
471  return AVERROR(EAGAIN);
472 
473  /* fetch new packet or eof */
474  ret = ff_decode_get_packet(avctx, &s->buffered_pkt);
475  if (ret == AVERROR_EOF) {
476  AVPacket null_pkt = { 0 };
477  ret = ff_mediacodec_dec_send(avctx, s->ctx, &null_pkt);
478  if (ret < 0)
479  return ret;
480  }
481  else if (ret < 0)
482  return ret;
483 
484  /* crank decoder with new packet */
485  return mediacodec_send_receive(avctx, s, frame, true);
486 }
487 
489 {
491 
493 
494  ff_mediacodec_dec_flush(avctx, s->ctx);
495 }
496 
498  &(const AVCodecHWConfigInternal) {
499  .public = {
503  .device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
504  },
505  .hwaccel = NULL,
506  },
507  NULL
508 };
509 
510 #if CONFIG_H264_MEDIACODEC_DECODER
512  .name = "h264_mediacodec",
513  .long_name = NULL_IF_CONFIG_SMALL("H.264 Android MediaCodec decoder"),
514  .type = AVMEDIA_TYPE_VIDEO,
515  .id = AV_CODEC_ID_H264,
516  .priv_data_size = sizeof(MediaCodecH264DecContext),
520  .close = mediacodec_decode_close,
522  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
523  .bsfs = "h264_mp4toannexb",
524  .hw_configs = mediacodec_hw_configs,
525  .wrapper_name = "mediacodec",
526 };
527 #endif
528 
529 #if CONFIG_HEVC_MEDIACODEC_DECODER
531  .name = "hevc_mediacodec",
532  .long_name = NULL_IF_CONFIG_SMALL("H.265 Android MediaCodec decoder"),
533  .type = AVMEDIA_TYPE_VIDEO,
534  .id = AV_CODEC_ID_HEVC,
535  .priv_data_size = sizeof(MediaCodecH264DecContext),
539  .close = mediacodec_decode_close,
541  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
542  .bsfs = "hevc_mp4toannexb",
543  .hw_configs = mediacodec_hw_configs,
544  .wrapper_name = "mediacodec",
545 };
546 #endif
547 
548 #if CONFIG_MPEG2_MEDIACODEC_DECODER
550  .name = "mpeg2_mediacodec",
551  .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 Android MediaCodec decoder"),
552  .type = AVMEDIA_TYPE_VIDEO,
554  .priv_data_size = sizeof(MediaCodecH264DecContext),
558  .close = mediacodec_decode_close,
560  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
561  .hw_configs = mediacodec_hw_configs,
562  .wrapper_name = "mediacodec",
563 };
564 #endif
565 
566 #if CONFIG_MPEG4_MEDIACODEC_DECODER
568  .name = "mpeg4_mediacodec",
569  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Android MediaCodec decoder"),
570  .type = AVMEDIA_TYPE_VIDEO,
571  .id = AV_CODEC_ID_MPEG4,
572  .priv_data_size = sizeof(MediaCodecH264DecContext),
576  .close = mediacodec_decode_close,
578  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
579  .hw_configs = mediacodec_hw_configs,
580  .wrapper_name = "mediacodec",
581 };
582 #endif
583 
584 #if CONFIG_VP8_MEDIACODEC_DECODER
586  .name = "vp8_mediacodec",
587  .long_name = NULL_IF_CONFIG_SMALL("VP8 Android MediaCodec decoder"),
588  .type = AVMEDIA_TYPE_VIDEO,
589  .id = AV_CODEC_ID_VP8,
590  .priv_data_size = sizeof(MediaCodecH264DecContext),
594  .close = mediacodec_decode_close,
596  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
597  .hw_configs = mediacodec_hw_configs,
598  .wrapper_name = "mediacodec",
599 };
600 #endif
601 
602 #if CONFIG_VP9_MEDIACODEC_DECODER
604  .name = "vp9_mediacodec",
605  .long_name = NULL_IF_CONFIG_SMALL("VP9 Android MediaCodec decoder"),
606  .type = AVMEDIA_TYPE_VIDEO,
607  .id = AV_CODEC_ID_VP9,
608  .priv_data_size = sizeof(MediaCodecH264DecContext),
612  .close = mediacodec_decode_close,
614  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
615  .hw_configs = mediacodec_hw_configs,
616  .wrapper_name = "mediacodec",
617 };
618 #endif
AVCodecHWConfig public
This is the structure which will be returned to the user by avcodec_get_hw_config().
Definition: hwaccel.h:34
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:768
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static const char * format[]
Definition: af_aiir.c:311
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
static const AVCodecHWConfigInternal * mediacodec_hw_configs[]
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:135
AVBufferRef * vps_list[HEVC_MAX_VPS_COUNT]
Definition: hevc_ps.h:395
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
static void flush(AVCodecContext *avctx)
AVBufferRef * sps_list[MAX_SPS_COUNT]
Definition: h264_ps.h:138
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
MediaCodecDecContext * ctx
Definition: mediacodecdec.c:43
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: avcodec.h:1054
Sequence parameter set.
Definition: h264_ps.h:43
int size
Definition: avcodec.h:1416
void ff_AMediaFormat_setBuffer(FFAMediaFormat *format, const char *name, void *data, size_t size)
static av_cold int mediacodec_decode_close(AVCodecContext *avctx)
Definition: mediacodecdec.c:49
Picture parameter set.
Definition: h264_ps.h:108
int out_size
Definition: movenc.c:55
H.265 parser code.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:236
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)
Definition: hevc_parse.c:77
static CopyRet receive_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame)
Definition: crystalhd.c:560
static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
#define src
Definition: vp8dsp.c:254
int ff_mediacodec_dec_close(AVCodecContext *avctx, MediaCodecDecContext *s)
AVCodec.
Definition: avcodec.h:3386
int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx, MediaCodecDecContext *s)
AVCodec ff_hevc_mediacodec_decoder
#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: avcodec.h:982
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
AVBufferRef * sps_list[HEVC_MAX_SPS_COUNT]
Definition: hevc_ps.h:396
uint8_t
#define av_cold
Definition: attributes.h:82
#define av_malloc(s)
AVOptions.
FFAMediaFormat * ff_AMediaFormat_new(void)
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
Definition: decode.c:294
enum AVPixelFormat pix_fmt
A hardware pixel format which the codec can use.
Definition: avcodec.h:3364
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1603
static AVFrame * frame
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)
Definition: h264_parse.c:443
#define MAX_PPS_COUNT
Definition: h264_ps.h:38
uint8_t * data
Definition: avcodec.h:1415
#define AVERROR_EOF
End of file.
Definition: error.h:55
AVBufferRef * pps_list[HEVC_MAX_PPS_COUNT]
Definition: hevc_ps.h:397
AVCodec ff_mpeg2_mediacodec_decoder
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AVERROR(e)
Definition: error.h:43
int data_size
Definition: hevc_ps.h:391
int ff_mediacodec_dec_flush(AVCodecContext *avctx, MediaCodecDecContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
Definition: avcodec.h:3393
static int mediacodec_send_receive(AVCodecContext *avctx, MediaCodecH264DecContext *s, AVFrame *frame, bool wait)
int ff_mediacodec_dec_receive(AVCodecContext *avctx, MediaCodecDecContext *s, AVFrame *frame, bool wait)
AVCodec ff_vp9_mediacodec_decoder
size_t data_size
Definition: h264_ps.h:102
AVCodec ff_vp8_mediacodec_decoder
uint8_t data[4096]
Definition: h264_ps.h:128
void ff_AMediaFormat_setInt32(FFAMediaFormat *format, const char *name, int32_t value)
int width
picture width / height.
Definition: avcodec.h:1675
AVCodec ff_mpeg4_mediacodec_decoder
int data_size
Definition: hevc_ps.h:215
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:220
void ff_AMediaFormat_setString(FFAMediaFormat *format, const char *name, const char *value)
void ff_hevc_ps_uninit(HEVCParamSets *ps)
Definition: hevc_ps.c:1712
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
Libavcodec external API header.
AVBufferRef * pps_list[MAX_PPS_COUNT]
Definition: h264_ps.h:139
enum AVCodecID codec_id
Definition: avcodec.h:1513
unsigned int sps_id
seq_parameter_set_id
Definition: hevc_ps.h:318
main external API structure.
Definition: avcodec.h:1503
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:592
uint8_t * data
The data buffer.
Definition: buffer.h:89
int extradata_size
Definition: avcodec.h:1604
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
unsigned int sps_id
Definition: h264_ps.h:109
int ff_AMediaFormat_delete(FFAMediaFormat *format)
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
static void mediacodec_decode_flush(AVCodecContext *avctx)
hardware decoding through MediaCodec
Definition: pixfmt.h:289
#define FF_CODEC_CAP_SETS_PKT_DTS
Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set AVFrame.pkt_dts manually.
Definition: internal.h:55
int data_size
Definition: hevc_ps.h:314
AVCodec ff_h264_mediacodec_decoder
common internal api header.
common internal and external API header
uint8_t data[4096]
Definition: h264_ps.h:101
size_t data_size
Definition: h264_ps.h:129
uint8_t data[4096]
Definition: hevc_ps.h:214
The codec supports this format by some ad-hoc method.
Definition: avcodec.h:3357
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
void ff_h264_ps_uninit(H264ParamSets *ps)
Uninit H264 param sets structure.
Definition: h264_ps.c:317
int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s, const char *mime, FFAMediaFormat *format)
void * priv_data
Definition: avcodec.h:1530
The codec supports this format via the hw_device_ctx interface.
Definition: avcodec.h:3332
pixel format definitions
uint8_t data[4096]
Definition: hevc_ps.h:313
int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, AVPacket *pkt)
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: avcodec.h:1039
FILE * out
Definition: movenc.c:54
#define av_freep(p)
H.264 decoder/parser shared code.
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:57
This structure stores compressed data.
Definition: avcodec.h:1392
uint8_t data[4096]
Definition: hevc_ps.h:390