FFmpeg  3.4.2
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/fifo.h"
29 #include "libavutil/opt.h"
30 #include "libavutil/intreadwrite.h"
31 #include "libavutil/pixfmt.h"
32 
33 #include "avcodec.h"
34 #include "h264_parse.h"
35 #include "hevc_parse.h"
36 #include "internal.h"
37 #include "mediacodec_wrapper.h"
38 #include "mediacodecdec_common.h"
39 
40 typedef struct MediaCodecH264DecContext {
41 
43 
45 
47 
49 
51 {
53 
54  ff_mediacodec_dec_close(avctx, s->ctx);
55  s->ctx = NULL;
56 
57  av_fifo_free(s->fifo);
58 
60 
61  return 0;
62 }
63 
64 #if CONFIG_H264_MEDIACODEC_DECODER || CONFIG_HEVC_MEDIACODEC_DECODER
65 static int h2645_ps_to_nalu(const uint8_t *src, int src_size, uint8_t **out, int *out_size)
66 {
67  int i;
68  int ret = 0;
69  uint8_t *p = NULL;
70  static const uint8_t nalu_header[] = { 0x00, 0x00, 0x00, 0x01 };
71 
72  if (!out || !out_size) {
73  return AVERROR(EINVAL);
74  }
75 
76  p = av_malloc(sizeof(nalu_header) + src_size);
77  if (!p) {
78  return AVERROR(ENOMEM);
79  }
80 
81  *out = p;
82  *out_size = sizeof(nalu_header) + src_size;
83 
84  memcpy(p, nalu_header, sizeof(nalu_header));
85  memcpy(p + sizeof(nalu_header), src, src_size);
86 
87  /* Escape 0x00, 0x00, 0x0{0-3} pattern */
88  for (i = 4; i < *out_size; i++) {
89  if (i < *out_size - 3 &&
90  p[i + 0] == 0 &&
91  p[i + 1] == 0 &&
92  p[i + 2] <= 3) {
93  uint8_t *new;
94 
95  *out_size += 1;
96  new = av_realloc(*out, *out_size);
97  if (!new) {
98  ret = AVERROR(ENOMEM);
99  goto done;
100  }
101  *out = p = new;
102 
103  i = i + 2;
104  memmove(p + i + 1, p + i, *out_size - (i + 1));
105  p[i] = 0x03;
106  }
107  }
108 done:
109  if (ret < 0) {
110  av_freep(out);
111  *out_size = 0;
112  }
113 
114  return ret;
115 }
116 #endif
117 
118 #if CONFIG_H264_MEDIACODEC_DECODER
119 static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
120 {
121  int i;
122  int ret;
123 
124  H264ParamSets ps;
125  const PPS *pps = NULL;
126  const SPS *sps = NULL;
127  int is_avc = 0;
128  int nal_length_size = 0;
129 
130  memset(&ps, 0, sizeof(ps));
131 
133  &ps, &is_avc, &nal_length_size, 0, avctx);
134  if (ret < 0) {
135  goto done;
136  }
137 
138  for (i = 0; i < MAX_PPS_COUNT; i++) {
139  if (ps.pps_list[i]) {
140  pps = (const PPS*)ps.pps_list[i]->data;
141  break;
142  }
143  }
144 
145  if (pps) {
146  if (ps.sps_list[pps->sps_id]) {
147  sps = (const SPS*)ps.sps_list[pps->sps_id]->data;
148  }
149  }
150 
151  if (pps && sps) {
152  uint8_t *data = NULL;
153  int data_size = 0;
154 
155  if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
156  goto done;
157  }
158  ff_AMediaFormat_setBuffer(format, "csd-0", (void*)data, data_size);
159  av_freep(&data);
160 
161  if ((ret = h2645_ps_to_nalu(pps->data, pps->data_size, &data, &data_size)) < 0) {
162  goto done;
163  }
164  ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, data_size);
165  av_freep(&data);
166  } else {
167  av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from extradata");
168  ret = AVERROR_INVALIDDATA;
169  }
170 
171 done:
172  ff_h264_ps_uninit(&ps);
173 
174  return ret;
175 }
176 #endif
177 
178 #if CONFIG_HEVC_MEDIACODEC_DECODER
179 static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
180 {
181  int i;
182  int ret;
183 
184  HEVCParamSets ps;
185  HEVCSEIContext sei;
186 
187  const HEVCVPS *vps = NULL;
188  const HEVCPPS *pps = NULL;
189  const HEVCSPS *sps = NULL;
190  int is_nalff = 0;
191  int nal_length_size = 0;
192 
193  uint8_t *vps_data = NULL;
194  uint8_t *sps_data = NULL;
195  uint8_t *pps_data = NULL;
196  int vps_data_size = 0;
197  int sps_data_size = 0;
198  int pps_data_size = 0;
199 
200  memset(&ps, 0, sizeof(ps));
201  memset(&sei, 0, sizeof(sei));
202 
204  &ps, &sei, &is_nalff, &nal_length_size, 0, 1, avctx);
205  if (ret < 0) {
206  goto done;
207  }
208 
209  for (i = 0; i < HEVC_MAX_VPS_COUNT; i++) {
210  if (ps.vps_list[i]) {
211  vps = (const HEVCVPS*)ps.vps_list[i]->data;
212  break;
213  }
214  }
215 
216  for (i = 0; i < HEVC_MAX_PPS_COUNT; i++) {
217  if (ps.pps_list[i]) {
218  pps = (const HEVCPPS*)ps.pps_list[i]->data;
219  break;
220  }
221  }
222 
223  if (pps) {
224  if (ps.sps_list[pps->sps_id]) {
225  sps = (const HEVCSPS*)ps.sps_list[pps->sps_id]->data;
226  }
227  }
228 
229  if (vps && pps && sps) {
230  uint8_t *data;
231  int data_size;
232 
233  if ((ret = h2645_ps_to_nalu(vps->data, vps->data_size, &vps_data, &vps_data_size)) < 0 ||
234  (ret = h2645_ps_to_nalu(sps->data, sps->data_size, &sps_data, &sps_data_size)) < 0 ||
235  (ret = h2645_ps_to_nalu(pps->data, pps->data_size, &pps_data, &pps_data_size)) < 0) {
236  goto done;
237  }
238 
239  data_size = vps_data_size + sps_data_size + pps_data_size;
240  data = av_mallocz(data_size);
241  if (!data) {
242  ret = AVERROR(ENOMEM);
243  goto done;
244  }
245 
246  memcpy(data , vps_data, vps_data_size);
247  memcpy(data + vps_data_size , sps_data, sps_data_size);
248  memcpy(data + vps_data_size + sps_data_size, pps_data, pps_data_size);
249 
250  ff_AMediaFormat_setBuffer(format, "csd-0", data, data_size);
251 
252  av_freep(&data);
253  } else {
254  av_log(avctx, AV_LOG_ERROR, "Could not extract VPS/PPS/SPS from extradata");
255  ret = AVERROR_INVALIDDATA;
256  }
257 
258 done:
259  ff_hevc_ps_uninit(&ps);
260 
261  av_freep(&vps_data);
262  av_freep(&sps_data);
263  av_freep(&pps_data);
264 
265  return ret;
266 }
267 #endif
268 
269 #if CONFIG_MPEG2_MEDIACODEC_DECODER
270 static int mpeg2_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
271 {
272  int ret = 0;
273 
274  if (avctx->extradata) {
275  ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
276  }
277 
278  return ret;
279 }
280 #endif
281 
282 #if CONFIG_MPEG4_MEDIACODEC_DECODER
283 static int mpeg4_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
284 {
285  int ret = 0;
286 
287  if (avctx->extradata) {
288  ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
289  }
290 
291  return ret;
292 }
293 #endif
294 
295 #if CONFIG_VP8_MEDIACODEC_DECODER || CONFIG_VP9_MEDIACODEC_DECODER
296 static int vpx_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
297 {
298  int ret = 0;
299 
300  if (avctx->extradata) {
301  ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
302  }
303 
304  return ret;
305 }
306 #endif
307 
309 {
310  int ret;
311 
312  const char *codec_mime = NULL;
313 
314  FFAMediaFormat *format = NULL;
316 
317  format = ff_AMediaFormat_new();
318  if (!format) {
319  av_log(avctx, AV_LOG_ERROR, "Failed to create media format\n");
320  ret = AVERROR_EXTERNAL;
321  goto done;
322  }
323 
324  switch (avctx->codec_id) {
325 #if CONFIG_H264_MEDIACODEC_DECODER
326  case AV_CODEC_ID_H264:
327  codec_mime = "video/avc";
328 
329  ret = h264_set_extradata(avctx, format);
330  if (ret < 0)
331  goto done;
332  break;
333 #endif
334 #if CONFIG_HEVC_MEDIACODEC_DECODER
335  case AV_CODEC_ID_HEVC:
336  codec_mime = "video/hevc";
337 
338  ret = hevc_set_extradata(avctx, format);
339  if (ret < 0)
340  goto done;
341  break;
342 #endif
343 #if CONFIG_MPEG2_MEDIACODEC_DECODER
345  codec_mime = "video/mpeg2";
346 
347  ret = mpeg2_set_extradata(avctx, format);
348  if (ret < 0)
349  goto done;
350  break;
351 #endif
352 #if CONFIG_MPEG4_MEDIACODEC_DECODER
353  case AV_CODEC_ID_MPEG4:
354  codec_mime = "video/mp4v-es",
355 
356  ret = mpeg4_set_extradata(avctx, format);
357  if (ret < 0)
358  goto done;
359  break;
360 #endif
361 #if CONFIG_VP8_MEDIACODEC_DECODER
362  case AV_CODEC_ID_VP8:
363  codec_mime = "video/x-vnd.on2.vp8";
364 
365  ret = vpx_set_extradata(avctx, format);
366  if (ret < 0)
367  goto done;
368  break;
369 #endif
370 #if CONFIG_VP9_MEDIACODEC_DECODER
371  case AV_CODEC_ID_VP9:
372  codec_mime = "video/x-vnd.on2.vp9";
373 
374  ret = vpx_set_extradata(avctx, format);
375  if (ret < 0)
376  goto done;
377  break;
378 #endif
379  default:
380  av_assert0(0);
381  }
382 
383  ff_AMediaFormat_setString(format, "mime", codec_mime);
384  ff_AMediaFormat_setInt32(format, "width", avctx->width);
385  ff_AMediaFormat_setInt32(format, "height", avctx->height);
386 
387  s->ctx = av_mallocz(sizeof(*s->ctx));
388  if (!s->ctx) {
389  av_log(avctx, AV_LOG_ERROR, "Failed to allocate MediaCodecDecContext\n");
390  ret = AVERROR(ENOMEM);
391  goto done;
392  }
393 
394  if ((ret = ff_mediacodec_dec_init(avctx, s->ctx, codec_mime, format)) < 0) {
395  s->ctx = NULL;
396  goto done;
397  }
398 
399  av_log(avctx, AV_LOG_INFO, "MediaCodec started successfully, ret = %d\n", ret);
400 
401  s->fifo = av_fifo_alloc(sizeof(AVPacket));
402  if (!s->fifo) {
403  ret = AVERROR(ENOMEM);
404  goto done;
405  }
406 
407 done:
408  if (format) {
409  ff_AMediaFormat_delete(format);
410  }
411 
412  if (ret < 0) {
414  }
415 
416  return ret;
417 }
418 
419 
421  int *got_frame, AVPacket *pkt)
422 {
424 
425  return ff_mediacodec_dec_decode(avctx, s->ctx, frame, got_frame, pkt);
426 }
427 
428 static int mediacodec_decode_frame(AVCodecContext *avctx, void *data,
429  int *got_frame, AVPacket *avpkt)
430 {
432  AVFrame *frame = data;
433  int ret;
434 
435  /* buffer the input packet */
436  if (avpkt->size) {
437  AVPacket input_pkt = { 0 };
438 
439  if (av_fifo_space(s->fifo) < sizeof(input_pkt)) {
440  ret = av_fifo_realloc2(s->fifo,
441  av_fifo_size(s->fifo) + sizeof(input_pkt));
442  if (ret < 0)
443  return ret;
444  }
445 
446  ret = av_packet_ref(&input_pkt, avpkt);
447  if (ret < 0)
448  return ret;
449  av_fifo_generic_write(s->fifo, &input_pkt, sizeof(input_pkt), NULL);
450  }
451 
452  /*
453  * MediaCodec.flush() discards both input and output buffers, thus we
454  * need to delay the call to this function until the user has released or
455  * renderered the frames he retains.
456  *
457  * After we have buffered an input packet, check if the codec is in the
458  * flushing state. If it is, we need to call ff_mediacodec_dec_flush.
459  *
460  * ff_mediacodec_dec_flush returns 0 if the flush cannot be performed on
461  * the codec (because the user retains frames). The codec stays in the
462  * flushing state.
463  *
464  * ff_mediacodec_dec_flush returns 1 if the flush can actually be
465  * performed on the codec. The codec leaves the flushing state and can
466  * process again packets.
467  *
468  * ff_mediacodec_dec_flush returns a negative value if an error has
469  * occurred.
470  *
471  */
472  if (ff_mediacodec_dec_is_flushing(avctx, s->ctx)) {
473  if (!ff_mediacodec_dec_flush(avctx, s->ctx)) {
474  return avpkt->size;
475  }
476  }
477 
478  /* process buffered data */
479  while (!*got_frame) {
480  /* prepare the input data */
481  if (s->buffered_pkt.size <= 0) {
483 
484  /* no more data */
485  if (av_fifo_size(s->fifo) < sizeof(AVPacket)) {
486  return avpkt->size ? avpkt->size :
487  ff_mediacodec_dec_decode(avctx, s->ctx, frame, got_frame, avpkt);
488  }
489 
491  }
492 
493  ret = mediacodec_process_data(avctx, frame, got_frame, &s->buffered_pkt);
494  if (ret < 0)
495  return ret;
496 
497  s->buffered_pkt.size -= ret;
498  s->buffered_pkt.data += ret;
499  }
500 
501  return avpkt->size;
502 }
503 
505 {
507 
508  while (av_fifo_size(s->fifo)) {
509  AVPacket pkt;
510  av_fifo_generic_read(s->fifo, &pkt, sizeof(pkt), NULL);
511  av_packet_unref(&pkt);
512  }
513  av_fifo_reset(s->fifo);
514 
516 
517  ff_mediacodec_dec_flush(avctx, s->ctx);
518 }
519 
520 #if CONFIG_H264_MEDIACODEC_DECODER
521 AVCodec ff_h264_mediacodec_decoder = {
522  .name = "h264_mediacodec",
523  .long_name = NULL_IF_CONFIG_SMALL("H.264 Android MediaCodec decoder"),
524  .type = AVMEDIA_TYPE_VIDEO,
525  .id = AV_CODEC_ID_H264,
526  .priv_data_size = sizeof(MediaCodecH264DecContext),
530  .close = mediacodec_decode_close,
532  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
533  .bsfs = "h264_mp4toannexb",
534 };
535 #endif
536 
537 #if CONFIG_HEVC_MEDIACODEC_DECODER
538 AVCodec ff_hevc_mediacodec_decoder = {
539  .name = "hevc_mediacodec",
540  .long_name = NULL_IF_CONFIG_SMALL("H.265 Android MediaCodec decoder"),
541  .type = AVMEDIA_TYPE_VIDEO,
542  .id = AV_CODEC_ID_HEVC,
543  .priv_data_size = sizeof(MediaCodecH264DecContext),
547  .close = mediacodec_decode_close,
549  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
550  .bsfs = "hevc_mp4toannexb",
551 };
552 #endif
553 
554 #if CONFIG_MPEG2_MEDIACODEC_DECODER
555 AVCodec ff_mpeg2_mediacodec_decoder = {
556  .name = "mpeg2_mediacodec",
557  .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 Android MediaCodec decoder"),
558  .type = AVMEDIA_TYPE_VIDEO,
560  .priv_data_size = sizeof(MediaCodecH264DecContext),
564  .close = mediacodec_decode_close,
566  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
567 };
568 #endif
569 
570 #if CONFIG_MPEG4_MEDIACODEC_DECODER
571 AVCodec ff_mpeg4_mediacodec_decoder = {
572  .name = "mpeg4_mediacodec",
573  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Android MediaCodec decoder"),
574  .type = AVMEDIA_TYPE_VIDEO,
575  .id = AV_CODEC_ID_MPEG4,
576  .priv_data_size = sizeof(MediaCodecH264DecContext),
580  .close = mediacodec_decode_close,
582  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
583 };
584 #endif
585 
586 #if CONFIG_VP8_MEDIACODEC_DECODER
587 AVCodec ff_vp8_mediacodec_decoder = {
588  .name = "vp8_mediacodec",
589  .long_name = NULL_IF_CONFIG_SMALL("VP8 Android MediaCodec decoder"),
590  .type = AVMEDIA_TYPE_VIDEO,
591  .id = AV_CODEC_ID_VP8,
592  .priv_data_size = sizeof(MediaCodecH264DecContext),
596  .close = mediacodec_decode_close,
598  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
599 };
600 #endif
601 
602 #if CONFIG_VP9_MEDIACODEC_DECODER
603 AVCodec ff_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 };
616 #endif
#define NULL
Definition: coverity.c:32
int ff_mediacodec_dec_decode(AVCodecContext *avctx, MediaCodecDecContext *s, AVFrame *frame, int *got_frame, AVPacket *pkt)
const char * s
Definition: avisynth_c.h:768
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:135
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
AVBufferRef * vps_list[HEVC_MAX_VPS_COUNT]
Definition: hevc_ps.h:395
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:42
Sequence parameter set.
Definition: h264_ps.h:43
int size
Definition: avcodec.h:1680
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:50
Picture parameter set.
Definition: h264_ps.h:108
int out_size
Definition: movenc.c:55
H.265 parser code.
static AVPacket pkt
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:3739
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
Definition: fifo.c:122
#define HEVC_MAX_VPS_COUNT
Definition: hevc.h:81
int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx, MediaCodecDecContext *s)
#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:1027
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
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)
static int mediacodec_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int av_fifo_space(const AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
Definition: fifo.c:82
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1876
static AVFrame * frame
const char data[16]
Definition: mxf.c:90
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:436
#define MAX_PPS_COUNT
Definition: h264_ps.h:38
uint8_t * data
Definition: avcodec.h:1679
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer.
Definition: fifo.c:55
AVBufferRef * pps_list[HEVC_MAX_PPS_COUNT]
Definition: hevc_ps.h:397
#define av_log(a,...)
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition: avpacket.c:627
#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:179
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
Definition: fifo.c:213
simple assert() macros that are a bit more flexible than ISO C assert().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:222
const char * name
Name of the codec implementation.
Definition: avcodec.h:3746
size_t data_size
Definition: h264_ps.h:102
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:1948
int data_size
Definition: hevc_ps.h:215
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:219
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:1778
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
Definition: fifo.c:77
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
Resize an AVFifoBuffer.
Definition: fifo.c:87
unsigned int sps_id
seq_parameter_set_id
Definition: hevc_ps.h:318
main external API structure.
Definition: avcodec.h:1761
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:618
uint8_t * data
The data buffer.
Definition: buffer.h:89
a very simple circular buffer FIFO implementation
int extradata_size
Definition: avcodec.h:1877
static const char * format
Definition: movenc.c:47
static int mediacodec_process_data(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
unsigned int sps_id
Definition: h264_ps.h:109
int ff_AMediaFormat_delete(FFAMediaFormat *format)
static void mediacodec_decode_flush(AVCodecContext *avctx)
#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
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
#define HEVC_MAX_PPS_COUNT
Definition: hevc.h:83
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:1803
pixel format definitions
uint8_t data[4096]
Definition: hevc_ps.h:313
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Definition: fifo.c:43
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: avcodec.h:1091
FILE * out
Definition: movenc.c:54
#define av_freep(p)
void av_fifo_reset(AVFifoBuffer *f)
Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied...
Definition: fifo.c:71
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:1656
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, HEVCSEIContext *sei, int *is_nalff, int *nal_length_size, int err_recognition, int apply_defdispwin, void *logctx)
Definition: hevc_parse.c:77
uint8_t data[4096]
Definition: hevc_ps.h:390