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/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  av_freep(&vps_data);
260  av_freep(&sps_data);
261  av_freep(&pps_data);
262 
263  return ret;
264 }
265 #endif
266 
267 #if CONFIG_MPEG2_MEDIACODEC_DECODER
268 static int mpeg2_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
269 {
270  int ret = 0;
271 
272  if (avctx->extradata) {
273  ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
274  }
275 
276  return ret;
277 }
278 #endif
279 
280 #if CONFIG_MPEG4_MEDIACODEC_DECODER
281 static int mpeg4_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
282 {
283  int ret = 0;
284 
285  if (avctx->extradata) {
286  ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
287  }
288 
289  return ret;
290 }
291 #endif
292 
293 #if CONFIG_VP8_MEDIACODEC_DECODER || CONFIG_VP9_MEDIACODEC_DECODER
294 static int vpx_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
295 {
296  int ret = 0;
297 
298  if (avctx->extradata) {
299  ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
300  }
301 
302  return ret;
303 }
304 #endif
305 
307 {
308  int ret;
309 
310  const char *codec_mime = NULL;
311 
312  FFAMediaFormat *format = NULL;
314 
315  format = ff_AMediaFormat_new();
316  if (!format) {
317  av_log(avctx, AV_LOG_ERROR, "Failed to create media format\n");
318  ret = AVERROR_EXTERNAL;
319  goto done;
320  }
321 
322  switch (avctx->codec_id) {
323 #if CONFIG_H264_MEDIACODEC_DECODER
324  case AV_CODEC_ID_H264:
325  codec_mime = "video/avc";
326 
327  ret = h264_set_extradata(avctx, format);
328  if (ret < 0)
329  goto done;
330  break;
331 #endif
332 #if CONFIG_HEVC_MEDIACODEC_DECODER
333  case AV_CODEC_ID_HEVC:
334  codec_mime = "video/hevc";
335 
336  ret = hevc_set_extradata(avctx, format);
337  if (ret < 0)
338  goto done;
339  break;
340 #endif
341 #if CONFIG_MPEG2_MEDIACODEC_DECODER
343  codec_mime = "video/mpeg2";
344 
345  ret = mpeg2_set_extradata(avctx, format);
346  if (ret < 0)
347  goto done;
348  break;
349 #endif
350 #if CONFIG_MPEG4_MEDIACODEC_DECODER
351  case AV_CODEC_ID_MPEG4:
352  codec_mime = "video/mp4v-es",
353 
354  ret = mpeg4_set_extradata(avctx, format);
355  if (ret < 0)
356  goto done;
357  break;
358 #endif
359 #if CONFIG_VP8_MEDIACODEC_DECODER
360  case AV_CODEC_ID_VP8:
361  codec_mime = "video/x-vnd.on2.vp8";
362 
363  ret = vpx_set_extradata(avctx, format);
364  if (ret < 0)
365  goto done;
366  break;
367 #endif
368 #if CONFIG_VP9_MEDIACODEC_DECODER
369  case AV_CODEC_ID_VP9:
370  codec_mime = "video/x-vnd.on2.vp9";
371 
372  ret = vpx_set_extradata(avctx, format);
373  if (ret < 0)
374  goto done;
375  break;
376 #endif
377  default:
378  av_assert0(0);
379  }
380 
381  ff_AMediaFormat_setString(format, "mime", codec_mime);
382  ff_AMediaFormat_setInt32(format, "width", avctx->width);
383  ff_AMediaFormat_setInt32(format, "height", avctx->height);
384 
385  s->ctx = av_mallocz(sizeof(*s->ctx));
386  if (!s->ctx) {
387  av_log(avctx, AV_LOG_ERROR, "Failed to allocate MediaCodecDecContext\n");
388  ret = AVERROR(ENOMEM);
389  goto done;
390  }
391 
392  if ((ret = ff_mediacodec_dec_init(avctx, s->ctx, codec_mime, format)) < 0) {
393  s->ctx = NULL;
394  goto done;
395  }
396 
397  av_log(avctx, AV_LOG_INFO, "MediaCodec started successfully, ret = %d\n", ret);
398 
399  s->fifo = av_fifo_alloc(sizeof(AVPacket));
400  if (!s->fifo) {
401  ret = AVERROR(ENOMEM);
402  goto done;
403  }
404 
405 done:
406  if (format) {
407  ff_AMediaFormat_delete(format);
408  }
409 
410  if (ret < 0) {
412  }
413 
414  return ret;
415 }
416 
417 
419  int *got_frame, AVPacket *pkt)
420 {
422 
423  return ff_mediacodec_dec_decode(avctx, s->ctx, frame, got_frame, pkt);
424 }
425 
426 static int mediacodec_decode_frame(AVCodecContext *avctx, void *data,
427  int *got_frame, AVPacket *avpkt)
428 {
430  AVFrame *frame = data;
431  int ret;
432 
433  /* buffer the input packet */
434  if (avpkt->size) {
435  AVPacket input_pkt = { 0 };
436 
437  if (av_fifo_space(s->fifo) < sizeof(input_pkt)) {
438  ret = av_fifo_realloc2(s->fifo,
439  av_fifo_size(s->fifo) + sizeof(input_pkt));
440  if (ret < 0)
441  return ret;
442  }
443 
444  ret = av_packet_ref(&input_pkt, avpkt);
445  if (ret < 0)
446  return ret;
447  av_fifo_generic_write(s->fifo, &input_pkt, sizeof(input_pkt), NULL);
448  }
449 
450  /*
451  * MediaCodec.flush() discards both input and output buffers, thus we
452  * need to delay the call to this function until the user has released or
453  * renderered the frames he retains.
454  *
455  * After we have buffered an input packet, check if the codec is in the
456  * flushing state. If it is, we need to call ff_mediacodec_dec_flush.
457  *
458  * ff_mediacodec_dec_flush returns 0 if the flush cannot be performed on
459  * the codec (because the user retains frames). The codec stays in the
460  * flushing state.
461  *
462  * ff_mediacodec_dec_flush returns 1 if the flush can actually be
463  * performed on the codec. The codec leaves the flushing state and can
464  * process again packets.
465  *
466  * ff_mediacodec_dec_flush returns a negative value if an error has
467  * occurred.
468  *
469  */
470  if (ff_mediacodec_dec_is_flushing(avctx, s->ctx)) {
471  if (!ff_mediacodec_dec_flush(avctx, s->ctx)) {
472  return avpkt->size;
473  }
474  }
475 
476  /* process buffered data */
477  while (!*got_frame) {
478  /* prepare the input data */
479  if (s->buffered_pkt.size <= 0) {
481 
482  /* no more data */
483  if (av_fifo_size(s->fifo) < sizeof(AVPacket)) {
484  return avpkt->size ? avpkt->size :
485  ff_mediacodec_dec_decode(avctx, s->ctx, frame, got_frame, avpkt);
486  }
487 
489  }
490 
491  ret = mediacodec_process_data(avctx, frame, got_frame, &s->buffered_pkt);
492  if (ret < 0)
493  return ret;
494 
495  s->buffered_pkt.size -= ret;
496  s->buffered_pkt.data += ret;
497  }
498 
499  return avpkt->size;
500 }
501 
503 {
505 
506  while (av_fifo_size(s->fifo)) {
507  AVPacket pkt;
508  av_fifo_generic_read(s->fifo, &pkt, sizeof(pkt), NULL);
509  av_packet_unref(&pkt);
510  }
511  av_fifo_reset(s->fifo);
512 
514 
515  ff_mediacodec_dec_flush(avctx, s->ctx);
516 }
517 
518 #if CONFIG_H264_MEDIACODEC_DECODER
519 AVCodec ff_h264_mediacodec_decoder = {
520  .name = "h264_mediacodec",
521  .long_name = NULL_IF_CONFIG_SMALL("H.264 Android MediaCodec decoder"),
522  .type = AVMEDIA_TYPE_VIDEO,
523  .id = AV_CODEC_ID_H264,
524  .priv_data_size = sizeof(MediaCodecH264DecContext),
528  .close = mediacodec_decode_close,
530  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
531  .bsfs = "h264_mp4toannexb",
532 };
533 #endif
534 
535 #if CONFIG_HEVC_MEDIACODEC_DECODER
536 AVCodec ff_hevc_mediacodec_decoder = {
537  .name = "hevc_mediacodec",
538  .long_name = NULL_IF_CONFIG_SMALL("H.265 Android MediaCodec decoder"),
539  .type = AVMEDIA_TYPE_VIDEO,
540  .id = AV_CODEC_ID_HEVC,
541  .priv_data_size = sizeof(MediaCodecH264DecContext),
545  .close = mediacodec_decode_close,
547  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
548  .bsfs = "hevc_mp4toannexb",
549 };
550 #endif
551 
552 #if CONFIG_MPEG2_MEDIACODEC_DECODER
553 AVCodec ff_mpeg2_mediacodec_decoder = {
554  .name = "mpeg2_mediacodec",
555  .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 Android MediaCodec decoder"),
556  .type = AVMEDIA_TYPE_VIDEO,
558  .priv_data_size = sizeof(MediaCodecH264DecContext),
562  .close = mediacodec_decode_close,
564  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
565 };
566 #endif
567 
568 #if CONFIG_MPEG4_MEDIACODEC_DECODER
569 AVCodec ff_mpeg4_mediacodec_decoder = {
570  .name = "mpeg4_mediacodec",
571  .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Android MediaCodec decoder"),
572  .type = AVMEDIA_TYPE_VIDEO,
573  .id = AV_CODEC_ID_MPEG4,
574  .priv_data_size = sizeof(MediaCodecH264DecContext),
578  .close = mediacodec_decode_close,
580  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
581 };
582 #endif
583 
584 #if CONFIG_VP8_MEDIACODEC_DECODER
585 AVCodec ff_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 };
598 #endif
599 
600 #if CONFIG_VP9_MEDIACODEC_DECODER
601 AVCodec ff_vp9_mediacodec_decoder = {
602  .name = "vp9_mediacodec",
603  .long_name = NULL_IF_CONFIG_SMALL("VP9 Android MediaCodec decoder"),
604  .type = AVMEDIA_TYPE_VIDEO,
605  .id = AV_CODEC_ID_VP9,
606  .priv_data_size = sizeof(MediaCodecH264DecContext),
610  .close = mediacodec_decode_close,
612  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
613 };
614 #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
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
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: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.
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
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
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:437
#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().
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)
#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