FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mediacodecdec_h2645.c
Go to the documentation of this file.
1 /*
2  * Android MediaCodec H.264 / H.265 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 #include "libavutil/atomic.h"
33 
34 #include "avcodec.h"
35 #include "h264_parse.h"
36 #include "hevc_parse.h"
37 #include "internal.h"
38 #include "mediacodecdec.h"
39 #include "mediacodec_wrapper.h"
40 
41 typedef struct MediaCodecH264DecContext {
42 
44 
46 
48 
50 
52 
54 {
56 
57  ff_mediacodec_dec_close(avctx, s->ctx);
58  s->ctx = NULL;
59 
60  av_fifo_free(s->fifo);
61 
62  av_bsf_free(&s->bsf);
64 
65  return 0;
66 }
67 
68 static int h2645_ps_to_nalu(const uint8_t *src, int src_size, uint8_t **out, int *out_size)
69 {
70  int i;
71  int ret = 0;
72  uint8_t *p = NULL;
73  static const uint8_t nalu_header[] = { 0x00, 0x00, 0x00, 0x01 };
74 
75  if (!out || !out_size) {
76  return AVERROR(EINVAL);
77  }
78 
79  p = av_malloc(sizeof(nalu_header) + src_size);
80  if (!p) {
81  return AVERROR(ENOMEM);
82  }
83 
84  *out = p;
85  *out_size = sizeof(nalu_header) + src_size;
86 
87  memcpy(p, nalu_header, sizeof(nalu_header));
88  memcpy(p + sizeof(nalu_header), src, src_size);
89 
90  /* Escape 0x00, 0x00, 0x0{0-3} pattern */
91  for (i = 4; i < *out_size; i++) {
92  if (i < *out_size - 3 &&
93  p[i + 0] == 0 &&
94  p[i + 1] == 0 &&
95  p[i + 2] <= 3) {
96  uint8_t *new;
97 
98  *out_size += 1;
99  new = av_realloc(*out, *out_size);
100  if (!new) {
101  ret = AVERROR(ENOMEM);
102  goto done;
103  }
104  *out = p = new;
105 
106  i = i + 2;
107  memmove(p + i + 1, p + i, *out_size - (i + 1));
108  p[i] = 0x03;
109  }
110  }
111 done:
112  if (ret < 0) {
113  av_freep(out);
114  *out_size = 0;
115  }
116 
117  return ret;
118 }
119 
120 #if CONFIG_H264_MEDIACODEC_DECODER
121 static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
122 {
123  int i;
124  int ret;
125 
126  H264ParamSets ps;
127  const PPS *pps = NULL;
128  const SPS *sps = NULL;
129  int is_avc = 0;
130  int nal_length_size = 0;
131 
132  memset(&ps, 0, sizeof(ps));
133 
135  &ps, &is_avc, &nal_length_size, 0, avctx);
136  if (ret < 0) {
137  goto done;
138  }
139 
140  for (i = 0; i < MAX_PPS_COUNT; i++) {
141  if (ps.pps_list[i]) {
142  pps = (const PPS*)ps.pps_list[i]->data;
143  break;
144  }
145  }
146 
147  if (pps) {
148  if (ps.sps_list[pps->sps_id]) {
149  sps = (const SPS*)ps.sps_list[pps->sps_id]->data;
150  }
151  }
152 
153  if (pps && sps) {
154  uint8_t *data = NULL;
155  int data_size = 0;
156 
157  if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
158  goto done;
159  }
160  ff_AMediaFormat_setBuffer(format, "csd-0", (void*)data, data_size);
161  av_freep(&data);
162 
163  if ((ret = h2645_ps_to_nalu(pps->data, pps->data_size, &data, &data_size)) < 0) {
164  goto done;
165  }
166  ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, data_size);
167  av_freep(&data);
168  } else {
169  av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from extradata");
170  ret = AVERROR_INVALIDDATA;
171  }
172 
173 done:
174  ff_h264_ps_uninit(&ps);
175 
176  return ret;
177 }
178 #endif
179 
180 #if CONFIG_HEVC_MEDIACODEC_DECODER
181 static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
182 {
183  int i;
184  int ret;
185 
186  HEVCParamSets ps;
187 
188  const HEVCVPS *vps = NULL;
189  const HEVCPPS *pps = NULL;
190  const HEVCSPS *sps = NULL;
191  int is_nalff = 0;
192  int nal_length_size = 0;
193 
194  uint8_t *vps_data = NULL;
195  uint8_t *sps_data = NULL;
196  uint8_t *pps_data = NULL;
197  int vps_data_size = 0;
198  int sps_data_size = 0;
199  int pps_data_size = 0;
200 
201  memset(&ps, 0, sizeof(ps));
202 
204  &ps, &is_nalff, &nal_length_size, 0, avctx);
205  if (ret < 0) {
206  goto done;
207  }
208 
209  for (i = 0; i < 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 < 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 
268 {
269  int ret;
270 
271  const char *codec_mime = NULL;
272 
273  const char *bsf_name = NULL;
274  const AVBitStreamFilter *bsf = NULL;
275 
276  FFAMediaFormat *format = NULL;
278 
279  format = ff_AMediaFormat_new();
280  if (!format) {
281  av_log(avctx, AV_LOG_ERROR, "Failed to create media format\n");
282  ret = AVERROR_EXTERNAL;
283  goto done;
284  }
285 
286  switch (avctx->codec_id) {
287 #if CONFIG_H264_MEDIACODEC_DECODER
288  case AV_CODEC_ID_H264:
289  codec_mime = "video/avc";
290  bsf_name = "h264_mp4toannexb";
291 
292  ret = h264_set_extradata(avctx, format);
293  if (ret < 0)
294  goto done;
295  break;
296 #endif
297 #if CONFIG_HEVC_MEDIACODEC_DECODER
298  case AV_CODEC_ID_HEVC:
299  codec_mime = "video/hevc";
300  bsf_name = "hevc_mp4toannexb";
301 
302  ret = hevc_set_extradata(avctx, format);
303  if (ret < 0)
304  goto done;
305  break;
306 #endif
307  default:
308  av_assert0(0);
309  }
310 
311  ff_AMediaFormat_setString(format, "mime", codec_mime);
312  ff_AMediaFormat_setInt32(format, "width", avctx->width);
313  ff_AMediaFormat_setInt32(format, "height", avctx->height);
314 
315  s->ctx = av_mallocz(sizeof(*s->ctx));
316  if (!s->ctx) {
317  av_log(avctx, AV_LOG_ERROR, "Failed to allocate MediaCodecDecContext\n");
318  ret = AVERROR(ENOMEM);
319  goto done;
320  }
321 
322  if ((ret = ff_mediacodec_dec_init(avctx, s->ctx, codec_mime, format)) < 0) {
323  s->ctx = NULL;
324  goto done;
325  }
326 
327  av_log(avctx, AV_LOG_INFO, "MediaCodec started successfully, ret = %d\n", ret);
328 
329  s->fifo = av_fifo_alloc(sizeof(AVPacket));
330  if (!s->fifo) {
331  ret = AVERROR(ENOMEM);
332  goto done;
333  }
334 
335  bsf = av_bsf_get_by_name(bsf_name);
336  if(!bsf) {
337  ret = AVERROR_BSF_NOT_FOUND;
338  goto done;
339  }
340 
341  if ((ret = av_bsf_alloc(bsf, &s->bsf))) {
342  goto done;
343  }
344 
345  if (((ret = avcodec_parameters_from_context(s->bsf->par_in, avctx)) < 0) ||
346  ((ret = av_bsf_init(s->bsf)) < 0)) {
347  goto done;
348  }
349 
351 
352 done:
353  if (format) {
354  ff_AMediaFormat_delete(format);
355  }
356 
357  if (ret < 0) {
359  }
360 
361  return ret;
362 }
363 
364 
366  int *got_frame, AVPacket *pkt)
367 {
369 
370  return ff_mediacodec_dec_decode(avctx, s->ctx, frame, got_frame, pkt);
371 }
372 
373 static int mediacodec_decode_frame(AVCodecContext *avctx, void *data,
374  int *got_frame, AVPacket *avpkt)
375 {
377  AVFrame *frame = data;
378  int ret;
379 
380  /* buffer the input packet */
381  if (avpkt->size) {
382  AVPacket input_pkt = { 0 };
383 
384  if (av_fifo_space(s->fifo) < sizeof(input_pkt)) {
385  ret = av_fifo_realloc2(s->fifo,
386  av_fifo_size(s->fifo) + sizeof(input_pkt));
387  if (ret < 0)
388  return ret;
389  }
390 
391  ret = av_packet_ref(&input_pkt, avpkt);
392  if (ret < 0)
393  return ret;
394  av_fifo_generic_write(s->fifo, &input_pkt, sizeof(input_pkt), NULL);
395  }
396 
397  /*
398  * MediaCodec.flush() discards both input and output buffers, thus we
399  * need to delay the call to this function until the user has released or
400  * renderered the frames he retains.
401  *
402  * After we have buffered an input packet, check if the codec is in the
403  * flushing state. If it is, we need to call ff_mediacodec_dec_flush.
404  *
405  * ff_mediacodec_dec_flush returns 0 if the flush cannot be performed on
406  * the codec (because the user retains frames). The codec stays in the
407  * flushing state.
408  *
409  * ff_mediacodec_dec_flush returns 1 if the flush can actually be
410  * performed on the codec. The codec leaves the flushing state and can
411  * process again packets.
412  *
413  * ff_mediacodec_dec_flush returns a negative value if an error has
414  * occurred.
415  *
416  */
417  if (ff_mediacodec_dec_is_flushing(avctx, s->ctx)) {
418  if (!ff_mediacodec_dec_flush(avctx, s->ctx)) {
419  return avpkt->size;
420  }
421  }
422 
423  /* process buffered data */
424  while (!*got_frame) {
425  /* prepare the input data -- convert to Annex B if needed */
426  if (s->filtered_pkt.size <= 0) {
427  AVPacket input_pkt = { 0 };
428 
430 
431  /* no more data */
432  if (av_fifo_size(s->fifo) < sizeof(AVPacket)) {
433  return avpkt->size ? avpkt->size :
434  ff_mediacodec_dec_decode(avctx, s->ctx, frame, got_frame, avpkt);
435  }
436 
437  av_fifo_generic_read(s->fifo, &input_pkt, sizeof(input_pkt), NULL);
438 
439  ret = av_bsf_send_packet(s->bsf, &input_pkt);
440  if (ret < 0) {
441  return ret;
442  }
443 
444  ret = av_bsf_receive_packet(s->bsf, &s->filtered_pkt);
445  if (ret == AVERROR(EAGAIN)) {
446  goto done;
447  }
448 
449  /* {h264,hevc}_mp4toannexb are used here and do not require flushing */
450  av_assert0(ret != AVERROR_EOF);
451 
452  if (ret < 0) {
453  return ret;
454  }
455  }
456 
457  ret = mediacodec_process_data(avctx, frame, got_frame, &s->filtered_pkt);
458  if (ret < 0)
459  return ret;
460 
461  s->filtered_pkt.size -= ret;
462  s->filtered_pkt.data += ret;
463  }
464 done:
465  return avpkt->size;
466 }
467 
469 {
471 
472  while (av_fifo_size(s->fifo)) {
473  AVPacket pkt;
474  av_fifo_generic_read(s->fifo, &pkt, sizeof(pkt), NULL);
475  av_packet_unref(&pkt);
476  }
477  av_fifo_reset(s->fifo);
478 
480 
481  ff_mediacodec_dec_flush(avctx, s->ctx);
482 }
483 
484 #if CONFIG_H264_MEDIACODEC_DECODER
485 AVCodec ff_h264_mediacodec_decoder = {
486  .name = "h264_mediacodec",
487  .long_name = NULL_IF_CONFIG_SMALL("H.264 Android MediaCodec decoder"),
488  .type = AVMEDIA_TYPE_VIDEO,
489  .id = AV_CODEC_ID_H264,
490  .priv_data_size = sizeof(MediaCodecH264DecContext),
494  .close = mediacodec_decode_close,
495  .capabilities = CODEC_CAP_DELAY,
496  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
497 };
498 #endif
499 
500 #if CONFIG_HEVC_MEDIACODEC_DECODER
501 AVCodec ff_hevc_mediacodec_decoder = {
502  .name = "hevc_mediacodec",
503  .long_name = NULL_IF_CONFIG_SMALL("H.265 Android MediaCodec decoder"),
504  .type = AVMEDIA_TYPE_VIDEO,
505  .id = AV_CODEC_ID_HEVC,
506  .priv_data_size = sizeof(MediaCodecH264DecContext),
510  .close = mediacodec_decode_close,
511  .capabilities = CODEC_CAP_DELAY,
512  .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
513 };
514 #endif
void av_bsf_free(AVBSFContext **ctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
Definition: bsf.c:36
#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
int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx, MediaCodecDecContext *s)
This structure describes decoded (raw) audio or video data.
Definition: frame.h:184
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:145
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
static void flush(AVCodecContext *avctx)
static void mediacodec_decode_flush(AVCodecContext *avctx)
AVBufferRef * sps_list[MAX_SPS_COUNT]
Definition: h264_ps.h:137
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
MediaCodecDecContext * ctx
Sequence parameter set.
Definition: h264_ps.h:43
The bitstream filter state.
Definition: avcodec.h:5737
int size
Definition: avcodec.h:1601
static int mediacodec_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
void ff_AMediaFormat_setBuffer(FFAMediaFormat *format, const char *name, void *data, size_t size)
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
Picture parameter set.
Definition: h264_ps.h:107
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:252
static AVPacket pkt
static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
AVBufferRef * vps_list[MAX_VPS_COUNT]
Definition: hevc.h:572
AVCodec.
Definition: avcodec.h:3599
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Definition: bsf.c:135
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
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **ctx)
Allocate a context for a given bitstream filter.
Definition: bsf.c:82
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
Definition: bsf.c:199
uint8_t
#define av_cold
Definition: attributes.h:82
#define av_malloc(s)
AVOptions.
FFAMediaFormat * ff_AMediaFormat_new(void)
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:1790
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:422
#define MAX_PPS_COUNT
Definition: h264_ps.h:38
uint8_t * data
Definition: avcodec.h:1600
#define AVERROR_EOF
End of file.
Definition: error.h:55
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer.
Definition: fifo.c:55
#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:576
static av_cold int mediacodec_decode_close(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define 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:1175
#define AVERROR(e)
Definition: error.h:43
int data_size
Definition: hevc.h:568
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
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:3606
int ff_mediacodec_dec_decode(AVCodecContext *avctx, MediaCodecDecContext *s, AVFrame *frame, int *got_frame, AVPacket *pkt)
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, int *is_nalff, int *nal_length_size, int err_recognition, void *logctx)
Definition: hevc_parse.c:72
size_t data_size
Definition: h264_ps.h:101
uint8_t data[4096]
Definition: h264_ps.h:127
void ff_AMediaFormat_setInt32(FFAMediaFormat *format, const char *name, int32_t value)
int width
picture width / height.
Definition: avcodec.h:1862
AVBufferRef * pps_list[MAX_PPS_COUNT]
Definition: hevc.h:574
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
Definition: bsf.c:176
static int h2645_ps_to_nalu(const uint8_t *src, int src_size, uint8_t **out, int *out_size)
#define AVERROR_BSF_NOT_FOUND
Bitstream filter not found.
Definition: error.h:49
int data_size
Definition: hevc.h:392
int ff_mediacodec_dec_close(AVCodecContext *avctx, MediaCodecDecContext *s)
#define src
Definition: vp9dsp.c:530
void ff_AMediaFormat_setString(FFAMediaFormat *format, const char *name, const char *value)
Definition: hevc.h:402
Definition: hevc.h:372
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
Definition: hevc.h:494
Libavcodec external API header.
AVBufferRef * pps_list[MAX_PPS_COUNT]
Definition: h264_ps.h:138
enum AVCodecID codec_id
Definition: avcodec.h:1692
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.h:495
#define MAX_VPS_COUNT
Definition: hevc.h:50
main external API structure.
Definition: avcodec.h:1675
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:567
uint8_t * data
The data buffer.
Definition: buffer.h:89
a very simple circular buffer FIFO implementation
int extradata_size
Definition: avcodec.h:1791
static const char * format
Definition: movenc.c:47
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
Definition: utils.c:4149
static int mediacodec_process_data(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
unsigned int sps_id
Definition: h264_ps.h:108
int ff_AMediaFormat_delete(FFAMediaFormat *format)
#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.h:491
common internal api header.
common internal and external API header
uint8_t data[4096]
Definition: h264_ps.h:100
size_t data_size
Definition: h264_ps.h:128
uint8_t data[4096]
Definition: hevc.h:391
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
Definition: avpacket.c:33
void ff_h264_ps_uninit(H264ParamSets *ps)
Uninit H264 param sets structure.
Definition: h264_ps.c:307
void * priv_data
Definition: avcodec.h:1717
pixel format definitions
uint8_t data[4096]
Definition: hevc.h:490
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Definition: fifo.c:43
int ff_mediacodec_dec_flush(AVCodecContext *avctx, MediaCodecDecContext *s)
FILE * out
Definition: movenc.c:54
#define av_freep(p)
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
Definition: ffmpeg.c:2035
int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s, const char *mime, FFAMediaFormat *format)
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:1577
AVCodecParameters * par_in
Parameters of the input stream.
Definition: avcodec.h:5763
AVBufferRef * sps_list[MAX_SPS_COUNT]
Definition: hevc.h:573
uint8_t data[4096]
Definition: hevc.h:567