FFmpeg
mediacodecenc.c
Go to the documentation of this file.
1 /*
2  * Android MediaCodec encoders
3  *
4  * Copyright (c) 2022 Zhao Zhili <zhilizhao@tencent.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 "config_components.h"
24 
25 #include "libavutil/avassert.h"
27 #include "libavutil/imgutils.h"
28 #include "libavutil/opt.h"
29 
30 #include "avcodec.h"
31 #include "bsf.h"
32 #include "codec_internal.h"
33 #include "encode.h"
34 #include "hwconfig.h"
35 #include "jni.h"
36 #include "mediacodec.h"
37 #include "mediacodec_wrapper.h"
38 #include "mediacodecdec_common.h"
39 #include "profiles.h"
40 
41 #define INPUT_DEQUEUE_TIMEOUT_US 8000
42 #define OUTPUT_DEQUEUE_TIMEOUT_US 8000
43 
45  /* Constant quality mode */
47  /* Variable bitrate mode */
49  /* Constant bitrate mode */
51  /* Constant bitrate mode with frame drops */
53 };
54 
55 typedef struct MediaCodecEncContext {
59  const char *name;
61 
62  int fps;
63  int width;
64  int height;
65 
66  uint8_t *extradata;
68  int eof_sent;
69 
72 
74  int level;
77 
78 enum {
81  COLOR_FormatSurface = 0x7F000789,
82 };
83 
84 static const struct {
87 } color_formats[] = {
91 };
92 
93 static const enum AVPixelFormat avc_pix_fmts[] = {
98 };
99 
101 {
102  MediaCodecEncContext *s = avctx->priv_data;
103  char *name = ff_AMediaCodec_getName(s->codec);
104  FFAMediaFormat *out_format = ff_AMediaCodec_getOutputFormat(s->codec);
105  char *str = ff_AMediaFormat_toString(out_format);
106 
107  av_log(avctx, AV_LOG_DEBUG, "MediaCodec encoder %s output format %s\n",
108  name ? name : "unknown", str);
109  av_free(name);
110  av_free(str);
111  ff_AMediaFormat_delete(out_format);
112 }
113 
115 {
116  MediaCodecEncContext *s = avctx->priv_data;
117  char str[128];
118  int ret;
119  int crop_right = s->width - avctx->width;
120  int crop_bottom = s->height - avctx->height;
121 
122  if (!crop_right && !crop_bottom)
123  return 0;
124 
125  if (avctx->codec_id == AV_CODEC_ID_H264)
126  ret = snprintf(str, sizeof(str), "h264_metadata=crop_right=%d:crop_bottom=%d",
127  crop_right, crop_bottom);
128  else if (avctx->codec_id == AV_CODEC_ID_HEVC)
129  ret = snprintf(str, sizeof(str), "hevc_metadata=crop_right=%d:crop_bottom=%d",
130  crop_right, crop_bottom);
131  else
132  return 0;
133 
134  if (ret >= sizeof(str))
136 
137  ret = av_bsf_list_parse_str(str, &s->bsf);
138  if (ret < 0)
139  return ret;
140 
141  ret = avcodec_parameters_from_context(s->bsf->par_in, avctx);
142  if (ret < 0)
143  return ret;
144  s->bsf->time_base_in = avctx->time_base;
145  ret = av_bsf_init(s->bsf);
146 
147  return ret;
148 }
149 
151 {
152  const char *codec_mime = NULL;
153  MediaCodecEncContext *s = avctx->priv_data;
155  int ret;
156  int gop;
157 
158  if (s->use_ndk_codec < 0)
159  s->use_ndk_codec = !av_jni_get_java_vm(avctx);
160 
161  switch (avctx->codec_id) {
162  case AV_CODEC_ID_H264:
163  codec_mime = "video/avc";
164  break;
165  case AV_CODEC_ID_HEVC:
166  codec_mime = "video/hevc";
167  break;
168  case AV_CODEC_ID_VP8:
169  codec_mime = "video/x-vnd.on2.vp8";
170  break;
171  case AV_CODEC_ID_VP9:
172  codec_mime = "video/x-vnd.on2.vp9";
173  break;
174  case AV_CODEC_ID_MPEG4:
175  codec_mime = "video/mp4v-es";
176  break;
177  case AV_CODEC_ID_AV1:
178  codec_mime = "video/av01";
179  break;
180  default:
181  av_assert0(0);
182  }
183 
184  if (s->name)
185  s->codec = ff_AMediaCodec_createCodecByName(s->name, s->use_ndk_codec);
186  else
187  s->codec = ff_AMediaCodec_createEncoderByType(codec_mime, s->use_ndk_codec);
188  if (!s->codec) {
189  av_log(avctx, AV_LOG_ERROR, "Failed to create encoder for type %s\n",
190  codec_mime);
191  return AVERROR_EXTERNAL;
192  }
193 
194  format = ff_AMediaFormat_new(s->use_ndk_codec);
195  if (!format) {
196  av_log(avctx, AV_LOG_ERROR, "Failed to create media format\n");
197  return AVERROR_EXTERNAL;
198  }
199 
200  ff_AMediaFormat_setString(format, "mime", codec_mime);
201  // Workaround the alignment requirement of mediacodec. We can't do it
202  // silently for AV_PIX_FMT_MEDIACODEC.
203  if (avctx->pix_fmt != AV_PIX_FMT_MEDIACODEC) {
204  s->width = FFALIGN(avctx->width, 16);
205  s->height = FFALIGN(avctx->height, 16);
206  } else {
207  s->width = avctx->width;
208  s->height = avctx->height;
209  if (s->width % 16 || s->height % 16)
210  av_log(avctx, AV_LOG_WARNING,
211  "Video size %dx%d isn't align to 16, it may have device compatibility issue\n",
212  s->width, s->height);
213  }
214  ff_AMediaFormat_setInt32(format, "width", s->width);
215  ff_AMediaFormat_setInt32(format, "height", s->height);
216 
217  if (avctx->pix_fmt == AV_PIX_FMT_MEDIACODEC) {
218  AVMediaCodecContext *user_ctx = avctx->hwaccel_context;
219  if (avctx->hw_device_ctx) {
220  AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)(avctx->hw_device_ctx->data);
221  AVMediaCodecDeviceContext *dev_ctx;
222 
223  if (device_ctx->type != AV_HWDEVICE_TYPE_MEDIACODEC || !device_ctx->hwctx) {
224  ret = AVERROR(EINVAL);
225  goto bailout;
226  }
227  dev_ctx = device_ctx->hwctx;
228  s->window = ff_mediacodec_surface_ref(dev_ctx->surface, dev_ctx->native_window, avctx);
229  }
230 
231  if (!s->window && user_ctx && user_ctx->surface)
232  s->window = ff_mediacodec_surface_ref(user_ctx->surface, NULL, avctx);
233 
234  if (!s->window) {
235  ret = AVERROR(EINVAL);
236  av_log(avctx, AV_LOG_ERROR, "Missing hw_device_ctx or hwaccel_context for AV_PIX_FMT_MEDIACODEC\n");
237  goto bailout;
238  }
239  /* Although there is a method ANativeWindow_toSurface() introduced in
240  * API level 26, it's easier and safe to always require a Surface for
241  * Java MediaCodec.
242  */
243  if (!s->use_ndk_codec && !s->window->surface) {
244  ret = AVERROR(EINVAL);
245  av_log(avctx, AV_LOG_ERROR, "Missing jobject Surface for AV_PIX_FMT_MEDIACODEC. "
246  "Please note that Java MediaCodec doesn't work with ANativeWindow.\n");
247  goto bailout;
248  }
249  }
250 
251  for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
252  if (avctx->pix_fmt == color_formats[i].pix_fmt) {
253  ff_AMediaFormat_setInt32(format, "color-format",
255  break;
256  }
257  }
258 
261  ff_AMediaFormat_setInt32(format, "color-range", ret);
264  ff_AMediaFormat_setInt32(format, "color-standard", ret);
267  ff_AMediaFormat_setInt32(format, "color-transfer", ret);
268 
269  if (avctx->bit_rate)
270  ff_AMediaFormat_setInt32(format, "bitrate", avctx->bit_rate);
271  if (s->bitrate_mode >= 0) {
272  ff_AMediaFormat_setInt32(format, "bitrate-mode", s->bitrate_mode);
273  if (s->bitrate_mode == BITRATE_MODE_CQ && avctx->global_quality > 0)
274  ff_AMediaFormat_setInt32(format, "quality", avctx->global_quality);
275  }
276  // frame-rate and i-frame-interval are required to configure codec
277  if (avctx->framerate.num >= avctx->framerate.den && avctx->framerate.den > 0) {
278  s->fps = avctx->framerate.num / avctx->framerate.den;
279  } else {
280  s->fps = 30;
281  av_log(avctx, AV_LOG_INFO, "Use %d as the default MediaFormat frame-rate\n", s->fps);
282  }
283  gop = round(avctx->gop_size / s->fps);
284  if (gop == 0) {
285  gop = 1;
286  av_log(avctx, AV_LOG_INFO,
287  "Use %d as the default MediaFormat i-frame-interval, "
288  "please set gop_size properly (>= fps)\n", gop);
289  } else {
290  av_log(avctx, AV_LOG_DEBUG, "Set i-frame-interval to %d\n", gop);
291  }
292 
293  ff_AMediaFormat_setInt32(format, "frame-rate", s->fps);
294  ff_AMediaFormat_setInt32(format, "i-frame-interval", gop);
295 
297  if (ret > 0) {
298  av_log(avctx, AV_LOG_DEBUG, "set profile to 0x%x\n", ret);
299  ff_AMediaFormat_setInt32(format, "profile", ret);
300  }
301  if (s->level > 0) {
302  av_log(avctx, AV_LOG_DEBUG, "set level to 0x%x\n", s->level);
303  ff_AMediaFormat_setInt32(format, "level", s->level);
304  }
305  if (avctx->max_b_frames > 0) {
307  av_log(avctx, AV_LOG_ERROR,
308  "Enabling B frames will produce packets with no DTS. "
309  "Use -strict experimental to use it anyway.\n");
310  ret = AVERROR(EINVAL);
311  goto bailout;
312  }
313  ff_AMediaFormat_setInt32(format, "max-bframes", avctx->max_b_frames);
314  }
315  if (s->pts_as_dts == -1)
316  s->pts_as_dts = avctx->max_b_frames <= 0;
317 
319  ret = ff_AMediaCodec_configure(s->codec, format, s->window, NULL, ret);
320  if (ret) {
321  av_log(avctx, AV_LOG_ERROR, "MediaCodec configure failed, %s\n", av_err2str(ret));
322  goto bailout;
323  }
324 
325  ret = ff_AMediaCodec_start(s->codec);
326  if (ret) {
327  av_log(avctx, AV_LOG_ERROR, "MediaCodec failed to start, %s\n", av_err2str(ret));
328  goto bailout;
329  }
330 
331  ret = mediacodec_init_bsf(avctx);
332  if (ret)
333  goto bailout;
334 
336  if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)
337  av_log(avctx, AV_LOG_WARNING,
338  "Mediacodec encoder doesn't support AV_CODEC_FLAG_GLOBAL_HEADER. "
339  "Use extract_extradata bsf when necessary.\n");
340 
341  s->frame = av_frame_alloc();
342  if (!s->frame)
343  ret = AVERROR(ENOMEM);
344 
345 bailout:
346  if (format)
348  return ret;
349 }
350 
352  AVPacket *pkt,
353  int *got_packet)
354 {
355  MediaCodecEncContext *s = avctx->priv_data;
356  FFAMediaCodec *codec = s->codec;
357  FFAMediaCodecBufferInfo out_info = {0};
358  uint8_t *out_buf;
359  size_t out_size = 0;
360  int ret;
361  int extradata_size = 0;
362  int64_t timeout_us = s->eof_sent ? OUTPUT_DEQUEUE_TIMEOUT_US : 0;
363  ssize_t index = ff_AMediaCodec_dequeueOutputBuffer(codec, &out_info, timeout_us);
364 
366  return AVERROR(EAGAIN);
367 
370  return AVERROR(EAGAIN);
371  }
372 
375  return AVERROR(EAGAIN);
376  }
377 
378  if (index < 0)
379  return AVERROR_EXTERNAL;
380 
381  if (out_info.flags & ff_AMediaCodec_getBufferFlagEndOfStream(codec))
382  return AVERROR_EOF;
383 
384  out_buf = ff_AMediaCodec_getOutputBuffer(codec, index, &out_size);
385  if (!out_buf) {
387  goto bailout;
388  }
389 
390  if (out_info.flags & ff_AMediaCodec_getBufferFlagCodecConfig(codec)) {
391  ret = av_reallocp(&s->extradata, out_info.size);
392  if (ret)
393  goto bailout;
394 
395  s->extradata_size = out_info.size;
396  memcpy(s->extradata, out_buf + out_info.offset, out_info.size);
398  // try immediately
399  return mediacodec_receive(avctx, pkt, got_packet);
400  }
401 
402  ret = ff_get_encode_buffer(avctx, pkt, out_info.size + s->extradata_size, 0);
403  if (ret < 0)
404  goto bailout;
405 
406  if (s->extradata_size) {
407  extradata_size = s->extradata_size;
408  s->extradata_size = 0;
409  memcpy(pkt->data, s->extradata, extradata_size);
410  }
411  memcpy(pkt->data + extradata_size, out_buf + out_info.offset, out_info.size);
413  if (s->pts_as_dts)
414  pkt->dts = pkt->pts;
415  if (out_info.flags & ff_AMediaCodec_getBufferFlagKeyFrame(codec))
417  ret = 0;
418  *got_packet = 1;
419 
420  av_log(avctx, AV_LOG_TRACE, "receive packet pts %" PRId64 " dts %" PRId64
421  " flags %d extradata %d\n",
422  pkt->pts, pkt->dts, pkt->flags, extradata_size);
423 
424 bailout:
426  return ret;
427 }
428 
429 static void copy_frame_to_buffer(AVCodecContext *avctx, const AVFrame *frame, uint8_t *dst, size_t size)
430 {
431  MediaCodecEncContext *s = avctx->priv_data;
432  uint8_t *dst_data[4] = {};
433  int dst_linesize[4] = {};
434 
435  if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) {
436  dst_data[0] = dst;
437  dst_data[1] = dst + s->width * s->height;
438  dst_data[2] = dst_data[1] + s->width * s->height / 4;
439 
440  dst_linesize[0] = s->width;
441  dst_linesize[1] = dst_linesize[2] = s->width / 2;
442  } else if (avctx->pix_fmt == AV_PIX_FMT_NV12) {
443  dst_data[0] = dst;
444  dst_data[1] = dst + s->width * s->height;
445 
446  dst_linesize[0] = s->width;
447  dst_linesize[1] = s->width;
448  } else {
449  av_assert0(0);
450  }
451 
452  av_image_copy2(dst_data, dst_linesize, frame->data, frame->linesize,
453  avctx->pix_fmt, avctx->width, avctx->height);
454 }
455 
456 static int mediacodec_send(AVCodecContext *avctx,
457  const AVFrame *frame) {
458  MediaCodecEncContext *s = avctx->priv_data;
459  FFAMediaCodec *codec = s->codec;
460  ssize_t index;
461  uint8_t *input_buf = NULL;
462  size_t input_size = 0;
463  int64_t pts = 0;
464  uint32_t flags = 0;
465  int64_t timeout_us;
466 
467  if (s->eof_sent)
468  return 0;
469 
470  if (s->window) {
471  if (!frame) {
472  s->eof_sent = 1;
474  }
475 
476  if (frame->data[3])
477  av_mediacodec_release_buffer((AVMediaCodecBuffer *)frame->data[3], 1);
478  return 0;
479  }
480 
481  timeout_us = INPUT_DEQUEUE_TIMEOUT_US;
482  index = ff_AMediaCodec_dequeueInputBuffer(codec, timeout_us);
484  return AVERROR(EAGAIN);
485 
486  if (index < 0) {
487  av_log(avctx, AV_LOG_ERROR, "dequeue input buffer failed, %zd", index);
488  return AVERROR_EXTERNAL;
489  }
490 
491  if (frame) {
492  input_buf = ff_AMediaCodec_getInputBuffer(codec, index, &input_size);
493  copy_frame_to_buffer(avctx, frame, input_buf, input_size);
494 
496  } else {
498  s->eof_sent = 1;
499  }
500 
501  ff_AMediaCodec_queueInputBuffer(codec, index, 0, input_size, pts, flags);
502  return 0;
503 }
504 
506 {
507  MediaCodecEncContext *s = avctx->priv_data;
508  int ret;
509  int got_packet = 0;
510 
511  // Return on three case:
512  // 1. Serious error
513  // 2. Got a packet success
514  // 3. No AVFrame is available yet (don't return if get_frame return EOF)
515  while (1) {
516  if (s->bsf) {
517  ret = av_bsf_receive_packet(s->bsf, pkt);
518  if (!ret)
519  return 0;
520  if (ret != AVERROR(EAGAIN))
521  return ret;
522  }
523 
524  ret = mediacodec_receive(avctx, pkt, &got_packet);
525  if (s->bsf) {
526  if (!ret || ret == AVERROR_EOF)
527  ret = av_bsf_send_packet(s->bsf, pkt);
528  } else {
529  if (!ret)
530  return 0;
531  }
532 
533  if (ret != AVERROR(EAGAIN))
534  return ret;
535 
536  if (!s->frame->buf[0]) {
537  ret = ff_encode_get_frame(avctx, s->frame);
538  if (ret && ret != AVERROR_EOF)
539  return ret;
540  }
541 
542  ret = mediacodec_send(avctx, s->frame->buf[0] ? s->frame : NULL);
543  if (!ret)
544  av_frame_unref(s->frame);
545  else if (ret != AVERROR(EAGAIN))
546  return ret;
547  }
548 
549  return 0;
550 }
551 
553 {
554  MediaCodecEncContext *s = avctx->priv_data;
555  if (s->codec) {
556  ff_AMediaCodec_stop(s->codec);
557  ff_AMediaCodec_delete(s->codec);
558  s->codec = NULL;
559  }
560 
561  if (s->window) {
562  ff_mediacodec_surface_unref(s->window, avctx);
563  s->window = NULL;
564  }
565 
566  av_bsf_free(&s->bsf);
567  av_frame_free(&s->frame);
568 
569  return 0;
570 }
571 
573  &(const AVCodecHWConfigInternal) {
574  .public = {
578  .device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
579  },
580  .hwaccel = NULL,
581  },
582  NULL
583 };
584 
585 #define OFFSET(x) offsetof(MediaCodecEncContext, x)
586 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
587 #define COMMON_OPTION \
588  { "ndk_codec", "Use MediaCodec from NDK", \
589  OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, \
590  { "codec_name", "Select codec by name", \
591  OFFSET(name), AV_OPT_TYPE_STRING, {0}, 0, 0, VE }, \
592  { "bitrate_mode", "Bitrate control method", \
593  OFFSET(bitrate_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, .unit = "bitrate_mode" }, \
594  { "cq", "Constant quality mode", \
595  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CQ}, 0, 0, VE, .unit = "bitrate_mode" }, \
596  { "vbr", "Variable bitrate mode", \
597  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_VBR}, 0, 0, VE, .unit = "bitrate_mode" }, \
598  { "cbr", "Constant bitrate mode", \
599  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CBR}, 0, 0, VE, .unit = "bitrate_mode" }, \
600  { "cbr_fd", "Constant bitrate mode with frame drops", \
601  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CBR_FD}, 0, 0, VE, .unit = "bitrate_mode" }, \
602  { "pts_as_dts", "Use PTS as DTS. It is enabled automatically if avctx max_b_frames <= 0, " \
603  "since most of Android devices don't output B frames by default.", \
604  OFFSET(pts_as_dts), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, \
605 
606 
607 #define MEDIACODEC_ENCODER_CLASS(name) \
608 static const AVClass name ## _mediacodec_class = { \
609  .class_name = #name "_mediacodec", \
610  .item_name = av_default_item_name, \
611  .option = name ## _options, \
612  .version = LIBAVUTIL_VERSION_INT, \
613 }; \
614 
615 #define DECLARE_MEDIACODEC_ENCODER(short_name, long_name, codec_id) \
616 MEDIACODEC_ENCODER_CLASS(short_name) \
617 const FFCodec ff_ ## short_name ## _mediacodec_encoder = { \
618  .p.name = #short_name "_mediacodec", \
619  CODEC_LONG_NAME(long_name " Android MediaCodec encoder"), \
620  .p.type = AVMEDIA_TYPE_VIDEO, \
621  .p.id = codec_id, \
622  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY \
623  | AV_CODEC_CAP_HARDWARE, \
624  .priv_data_size = sizeof(MediaCodecEncContext), \
625  .p.pix_fmts = avc_pix_fmts, \
626  .init = mediacodec_init, \
627  FF_CODEC_RECEIVE_PACKET_CB(mediacodec_encode), \
628  .close = mediacodec_close, \
629  .p.priv_class = &short_name ## _mediacodec_class, \
630  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \
631  .p.wrapper_name = "mediacodec", \
632  .hw_configs = mediacodec_hw_configs, \
633 }; \
634 
635 #if CONFIG_H264_MEDIACODEC_ENCODER
636 
637 enum MediaCodecAvcLevel {
638  AVCLevel1 = 0x01,
639  AVCLevel1b = 0x02,
640  AVCLevel11 = 0x04,
641  AVCLevel12 = 0x08,
642  AVCLevel13 = 0x10,
643  AVCLevel2 = 0x20,
644  AVCLevel21 = 0x40,
645  AVCLevel22 = 0x80,
646  AVCLevel3 = 0x100,
647  AVCLevel31 = 0x200,
648  AVCLevel32 = 0x400,
649  AVCLevel4 = 0x800,
650  AVCLevel41 = 0x1000,
651  AVCLevel42 = 0x2000,
652  AVCLevel5 = 0x4000,
653  AVCLevel51 = 0x8000,
654  AVCLevel52 = 0x10000,
655  AVCLevel6 = 0x20000,
656  AVCLevel61 = 0x40000,
657  AVCLevel62 = 0x80000,
658 };
659 
660 static const AVOption h264_options[] = {
662 
664  FF_AVCTX_PROFILE_OPTION("constrained_baseline", NULL, VIDEO, AV_PROFILE_H264_CONSTRAINED_BASELINE)
671 
672  { "level", "Specify level",
673  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
674  { "1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel1 }, 0, 0, VE, .unit = "level" },
675  { "1b", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel1b }, 0, 0, VE, .unit = "level" },
676  { "1.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel11 }, 0, 0, VE, .unit = "level" },
677  { "1.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel12 }, 0, 0, VE, .unit = "level" },
678  { "1.3", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel13 }, 0, 0, VE, .unit = "level" },
679  { "2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel2 }, 0, 0, VE, .unit = "level" },
680  { "2.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel21 }, 0, 0, VE, .unit = "level" },
681  { "2.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel22 }, 0, 0, VE, .unit = "level" },
682  { "3", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel3 }, 0, 0, VE, .unit = "level" },
683  { "3.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel31 }, 0, 0, VE, .unit = "level" },
684  { "3.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel32 }, 0, 0, VE, .unit = "level" },
685  { "4", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel4 }, 0, 0, VE, .unit = "level" },
686  { "4.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel41 }, 0, 0, VE, .unit = "level" },
687  { "4.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel42 }, 0, 0, VE, .unit = "level" },
688  { "5", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel5 }, 0, 0, VE, .unit = "level" },
689  { "5.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel51 }, 0, 0, VE, .unit = "level" },
690  { "5.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel52 }, 0, 0, VE, .unit = "level" },
691  { "6.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel6 }, 0, 0, VE, .unit = "level" },
692  { "6.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel61 }, 0, 0, VE, .unit = "level" },
693  { "6.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel62 }, 0, 0, VE, .unit = "level" },
694  { NULL, }
695 };
696 
698 
699 #endif // CONFIG_H264_MEDIACODEC_ENCODER
700 
701 #if CONFIG_HEVC_MEDIACODEC_ENCODER
702 
703 enum MediaCodecHevcLevel {
704  HEVCMainTierLevel1 = 0x1,
705  HEVCHighTierLevel1 = 0x2,
706  HEVCMainTierLevel2 = 0x4,
707  HEVCHighTierLevel2 = 0x8,
708  HEVCMainTierLevel21 = 0x10,
709  HEVCHighTierLevel21 = 0x20,
710  HEVCMainTierLevel3 = 0x40,
711  HEVCHighTierLevel3 = 0x80,
712  HEVCMainTierLevel31 = 0x100,
713  HEVCHighTierLevel31 = 0x200,
714  HEVCMainTierLevel4 = 0x400,
715  HEVCHighTierLevel4 = 0x800,
716  HEVCMainTierLevel41 = 0x1000,
717  HEVCHighTierLevel41 = 0x2000,
718  HEVCMainTierLevel5 = 0x4000,
719  HEVCHighTierLevel5 = 0x8000,
720  HEVCMainTierLevel51 = 0x10000,
721  HEVCHighTierLevel51 = 0x20000,
722  HEVCMainTierLevel52 = 0x40000,
723  HEVCHighTierLevel52 = 0x80000,
724  HEVCMainTierLevel6 = 0x100000,
725  HEVCHighTierLevel6 = 0x200000,
726  HEVCMainTierLevel61 = 0x400000,
727  HEVCHighTierLevel61 = 0x800000,
728  HEVCMainTierLevel62 = 0x1000000,
729  HEVCHighTierLevel62 = 0x2000000,
730 };
731 
732 static const AVOption hevc_options[] = {
734 
737 
738  { "level", "Specify tier and level",
739  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
740  { "m1", "Main tier level 1",
741  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel1 }, 0, 0, VE, .unit = "level" },
742  { "h1", "High tier level 1",
743  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel1 }, 0, 0, VE, .unit = "level" },
744  { "m2", "Main tier level 2",
745  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel2 }, 0, 0, VE, .unit = "level" },
746  { "h2", "High tier level 2",
747  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel2 }, 0, 0, VE, .unit = "level" },
748  { "m2.1", "Main tier level 2.1",
749  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel21 }, 0, 0, VE, .unit = "level" },
750  { "h2.1", "High tier level 2.1",
751  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel21 }, 0, 0, VE, .unit = "level" },
752  { "m3", "Main tier level 3",
753  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel3 }, 0, 0, VE, .unit = "level" },
754  { "h3", "High tier level 3",
755  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel3 }, 0, 0, VE, .unit = "level" },
756  { "m3.1", "Main tier level 3.1",
757  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel31 }, 0, 0, VE, .unit = "level" },
758  { "h3.1", "High tier level 3.1",
759  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel31 }, 0, 0, VE, .unit = "level" },
760  { "m4", "Main tier level 4",
761  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel4 }, 0, 0, VE, .unit = "level" },
762  { "h4", "High tier level 4",
763  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel4 }, 0, 0, VE, .unit = "level" },
764  { "m4.1", "Main tier level 4.1",
765  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel41 }, 0, 0, VE, .unit = "level" },
766  { "h4.1", "High tier level 4.1",
767  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel41 }, 0, 0, VE, .unit = "level" },
768  { "m5", "Main tier level 5",
769  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel5 }, 0, 0, VE, .unit = "level" },
770  { "h5", "High tier level 5",
771  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel5 }, 0, 0, VE, .unit = "level" },
772  { "m5.1", "Main tier level 5.1",
773  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel51 }, 0, 0, VE, .unit = "level" },
774  { "h5.1", "High tier level 5.1",
775  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel51 }, 0, 0, VE, .unit = "level" },
776  { "m5.2", "Main tier level 5.2",
777  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel52 }, 0, 0, VE, .unit = "level" },
778  { "h5.2", "High tier level 5.2",
779  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel52 }, 0, 0, VE, .unit = "level" },
780  { "m6", "Main tier level 6",
781  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel6 }, 0, 0, VE, .unit = "level" },
782  { "h6", "High tier level 6",
783  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel6 }, 0, 0, VE, .unit = "level" },
784  { "m6.1", "Main tier level 6.1",
785  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel61 }, 0, 0, VE, .unit = "level" },
786  { "h6.1", "High tier level 6.1",
787  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel61 }, 0, 0, VE, .unit = "level" },
788  { "m6.2", "Main tier level 6.2",
789  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel62 }, 0, 0, VE, .unit = "level" },
790  { "h6.2", "High tier level 6.2",
791  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel62 }, 0, 0, VE, .unit = "level" },
792  { NULL, }
793 };
794 
796 
797 #endif // CONFIG_HEVC_MEDIACODEC_ENCODER
798 
799 #if CONFIG_VP8_MEDIACODEC_ENCODER
800 
801 enum MediaCodecVP8Level {
802  VP8Level_Version0 = 0x01,
803  VP8Level_Version1 = 0x02,
804  VP8Level_Version2 = 0x04,
805  VP8Level_Version3 = 0x08,
806 };
807 
808 static const AVOption vp8_options[] = {
810  { "level", "Specify tier and level",
811  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
812  { "V0", "Level Version 0",
813  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version0 }, 0, 0, VE, .unit = "level" },
814  { "V1", "Level Version 1",
815  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version1 }, 0, 0, VE, .unit = "level" },
816  { "V2", "Level Version 2",
817  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version2 }, 0, 0, VE, .unit = "level" },
818  { "V3", "Level Version 3",
819  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version3 }, 0, 0, VE, .unit = "level" },
820  { NULL, }
821 };
822 
824 
825 #endif // CONFIG_VP8_MEDIACODEC_ENCODER
826 
827 #if CONFIG_VP9_MEDIACODEC_ENCODER
828 
829 enum MediaCodecVP9Level {
830  VP9Level1 = 0x1,
831  VP9Level11 = 0x2,
832  VP9Level2 = 0x4,
833  VP9Level21 = 0x8,
834  VP9Level3 = 0x10,
835  VP9Level31 = 0x20,
836  VP9Level4 = 0x40,
837  VP9Level41 = 0x80,
838  VP9Level5 = 0x100,
839  VP9Level51 = 0x200,
840  VP9Level52 = 0x400,
841  VP9Level6 = 0x800,
842  VP9Level61 = 0x1000,
843  VP9Level62 = 0x2000,
844 };
845 
846 static const AVOption vp9_options[] = {
848 
849  FF_AVCTX_PROFILE_OPTION("profile0", NULL, VIDEO, AV_PROFILE_VP9_0)
850  FF_AVCTX_PROFILE_OPTION("profile1", NULL, VIDEO, AV_PROFILE_VP9_1)
851  FF_AVCTX_PROFILE_OPTION("profile2", NULL, VIDEO, AV_PROFILE_VP9_2)
852  FF_AVCTX_PROFILE_OPTION("profile3", NULL, VIDEO, AV_PROFILE_VP9_3)
853 
854  { "level", "Specify tier and level",
855  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
856  { "1", "Level 1",
857  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level1 }, 0, 0, VE, .unit = "level" },
858  { "1.1", "Level 1.1",
859  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level11 }, 0, 0, VE, .unit = "level" },
860  { "2", "Level 2",
861  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level2 }, 0, 0, VE, .unit = "level" },
862  { "2.1", "Level 2.1",
863  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level21 }, 0, 0, VE, .unit = "level" },
864  { "3", "Level 3",
865  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level3 }, 0, 0, VE, .unit = "level" },
866  { "3.1", "Level 3.1",
867  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level31 }, 0, 0, VE, .unit = "level" },
868  { "4", "Level 4",
869  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level4 }, 0, 0, VE, .unit = "level" },
870  { "4.1", "Level 4.1",
871  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level41 }, 0, 0, VE, .unit = "level" },
872  { "5", "Level 5",
873  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level5 }, 0, 0, VE, .unit = "level" },
874  { "5.1", "Level 5.1",
875  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level51 }, 0, 0, VE, .unit = "level" },
876  { "5.2", "Level 5.2",
877  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level52 }, 0, 0, VE, .unit = "level" },
878  { "6", "Level 6",
879  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level6 }, 0, 0, VE, .unit = "level" },
880  { "6.1", "Level 4.1",
881  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level61 }, 0, 0, VE, .unit = "level" },
882  { "6.2", "Level 6.2",
883  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level62 }, 0, 0, VE, .unit = "level" },
884  { NULL, }
885 };
886 
888 
889 #endif // CONFIG_VP9_MEDIACODEC_ENCODER
890 
891 #if CONFIG_MPEG4_MEDIACODEC_ENCODER
892 
893 enum MediaCodecMpeg4Level {
894  MPEG4Level0 = 0x01,
895  MPEG4Level0b = 0x02,
896  MPEG4Level1 = 0x04,
897  MPEG4Level2 = 0x08,
898  MPEG4Level3 = 0x10,
899  MPEG4Level3b = 0x18,
900  MPEG4Level4 = 0x20,
901  MPEG4Level4a = 0x40,
902  MPEG4Level5 = 0x80,
903  MPEG4Level6 = 0x100,
904 };
905 
906 static const AVOption mpeg4_options[] = {
908 
910 
911  { "level", "Specify tier and level",
912  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
913  { "0", "Level 0",
914  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level0 }, 0, 0, VE, .unit = "level" },
915  { "0b", "Level 0b",
916  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level0b }, 0, 0, VE, .unit = "level" },
917  { "1", "Level 1",
918  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level1 }, 0, 0, VE, .unit = "level" },
919  { "2", "Level 2",
920  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level2 }, 0, 0, VE, .unit = "level" },
921  { "3", "Level 3",
922  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level3 }, 0, 0, VE, .unit = "level" },
923  { "3b", "Level 3b",
924  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level3b }, 0, 0, VE, .unit = "level" },
925  { "4", "Level 4",
926  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level4 }, 0, 0, VE, .unit = "level" },
927  { "4a", "Level 4a",
928  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level4a }, 0, 0, VE, .unit = "level" },
929  { "5", "Level 5",
930  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level5 }, 0, 0, VE, .unit = "level" },
931  { "6", "Level 6",
932  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level6 }, 0, 0, VE, .unit = "level" },
933  { NULL, }
934 };
935 
937 
938 #endif // CONFIG_MPEG4_MEDIACODEC_ENCODER
939 
940 #if CONFIG_AV1_MEDIACODEC_ENCODER
941 
942 enum MediaCodecAV1Level {
943  AV1Level2 = 0x1,
944  AV1Level21 = 0x2,
945  AV1Level22 = 0x4,
946  AV1Level23 = 0x8,
947  AV1Level3 = 0x10,
948  AV1Level31 = 0x20,
949  AV1Level32 = 0x40,
950  AV1Level33 = 0x80,
951  AV1Level4 = 0x100,
952  AV1Level41 = 0x200,
953  AV1Level42 = 0x400,
954  AV1Level43 = 0x800,
955  AV1Level5 = 0x1000,
956  AV1Level51 = 0x2000,
957  AV1Level52 = 0x4000,
958  AV1Level53 = 0x8000,
959  AV1Level6 = 0x10000,
960  AV1Level61 = 0x20000,
961  AV1Level62 = 0x40000,
962  AV1Level63 = 0x80000,
963  AV1Level7 = 0x100000,
964  AV1Level71 = 0x200000,
965  AV1Level72 = 0x400000,
966  AV1Level73 = 0x800000,
967 };
968 
969 static const AVOption av1_options[] = {
971 
973 
974  { "level", "Specify tier and level",
975  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
976  { "2", "Level 2",
977  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level2 }, 0, 0, VE, .unit = "level" },
978  { "2.1", "Level 2.1",
979  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level21 }, 0, 0, VE, .unit = "level" },
980  { "2.2", "Level 2.2",
981  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level22 }, 0, 0, VE, .unit = "level" },
982  { "2.3", "Level 2.3",
983  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level23 }, 0, 0, VE, .unit = "level" },
984  { "3", "Level 3",
985  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level3 }, 0, 0, VE, .unit = "level" },
986  { "3.1", "Level 3.1",
987  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level31 }, 0, 0, VE, .unit = "level" },
988  { "3.2", "Level 3.2",
989  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level32 }, 0, 0, VE, .unit = "level" },
990  { "3.3", "Level 3.3",
991  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level33 }, 0, 0, VE, .unit = "level" },
992  { "4", "Level 4",
993  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level4 }, 0, 0, VE, .unit = "level" },
994  { "4.1", "Level 4.1",
995  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level41 }, 0, 0, VE, .unit = "level" },
996  { "4.2", "Level 4.2",
997  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level42 }, 0, 0, VE, .unit = "level" },
998  { "4.3", "Level 4.3",
999  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level43 }, 0, 0, VE, .unit = "level" },
1000  { "5", "Level 5",
1001  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level5 }, 0, 0, VE, .unit = "level" },
1002  { "5.1", "Level 5.1",
1003  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level51 }, 0, 0, VE, .unit = "level" },
1004  { "5.2", "Level 5.2",
1005  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level52 }, 0, 0, VE, .unit = "level" },
1006  { "5.3", "Level 5.3",
1007  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level53 }, 0, 0, VE, .unit = "level" },
1008  { "6", "Level 6",
1009  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level6 }, 0, 0, VE, .unit = "level" },
1010  { "6.1", "Level 6.1",
1011  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level61 }, 0, 0, VE, .unit = "level" },
1012  { "6.2", "Level 6.2",
1013  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level62 }, 0, 0, VE, .unit = "level" },
1014  { "6.3", "Level 6.3",
1015  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level63 }, 0, 0, VE, .unit = "level" },
1016  { "7", "Level 7",
1017  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level7 }, 0, 0, VE, .unit = "level" },
1018  { "7.1", "Level 7.1",
1019  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level71 }, 0, 0, VE, .unit = "level" },
1020  { "7.2", "Level 7.2",
1021  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level72 }, 0, 0, VE, .unit = "level" },
1022  { "7.3", "Level 7.3",
1023  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level73 }, 0, 0, VE, .unit = "level" },
1024  { NULL, }
1025 };
1026 
1028 
1029 #endif // CONFIG_AV1_MEDIACODEC_ENCODER
MediaCodecEncContext
Definition: mediacodecenc.c:55
ff_AMediaCodec_getInputBuffer
static uint8_t * ff_AMediaCodec_getInputBuffer(FFAMediaCodec *codec, size_t idx, size_t *out_size)
Definition: mediacodec_wrapper.h:261
hwconfig.h
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:93
AVCodecContext::hwaccel_context
void * hwaccel_context
Legacy hardware accelerator context.
Definition: avcodec.h:1463
ff_AMediaFormat_delete
static int ff_AMediaFormat_delete(FFAMediaFormat *format)
Definition: mediacodec_wrapper.h:92
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
ff_AMediaCodec_delete
static int ff_AMediaCodec_delete(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:256
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
level
uint8_t level
Definition: svq3.c:204
MediaCodecEncContext::pts_as_dts
int pts_as_dts
Definition: mediacodecenc.c:75
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:1033
DECLARE_MEDIACODEC_ENCODER
#define DECLARE_MEDIACODEC_ENCODER(short_name, long_name, codec_id)
Definition: mediacodecenc.c:615
ff_AMediaCodec_start
static int ff_AMediaCodec_start(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:241
FFAMediaCodecBufferInfo::offset
int32_t offset
Definition: mediacodec_wrapper.h:173
MediaCodecEncContext::avclass
AVClass * avclass
Definition: mediacodecenc.c:56
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AV_PROFILE_H264_MAIN
#define AV_PROFILE_H264_MAIN
Definition: defs.h:111
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:264
color_format
int color_format
Definition: mediacodecenc.c:85
BITRATE_MODE_VBR
@ BITRATE_MODE_VBR
Definition: mediacodecenc.c:48
AV_PROFILE_VP9_1
#define AV_PROFILE_VP9_1
Definition: defs.h:154
AVMediaCodecDeviceContext::surface
void * surface
android/view/Surface handle, to be filled by the user.
Definition: hwcontext_mediacodec.h:33
FF_AV1_PROFILE_OPTS
#define FF_AV1_PROFILE_OPTS
Definition: profiles.h:54
MediaCodecEncContext::fps
int fps
Definition: mediacodecenc.c:62
AV_PROFILE_HEVC_MAIN
#define AV_PROFILE_HEVC_MAIN
Definition: defs.h:158
out_size
int out_size
Definition: movenc.c:55
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:64
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:100
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:452
ff_AMediaCodec_signalEndOfInputStream
static int ff_AMediaCodec_signalEndOfInputStream(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:341
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:1026
MediaCodecEncContext::window
FFANativeWindow * window
Definition: mediacodecenc.c:60
AVPacket::data
uint8_t * data
Definition: packet.h:522
ff_AMediaFormat_setString
static void ff_AMediaFormat_setString(FFAMediaFormat *format, const char *name, const char *value)
Definition: mediacodec_wrapper.h:150
BitrateMode
BitrateMode
Definition: mediacodecenc.c:44
ff_AMediaCodec_infoOutputFormatChanged
static int ff_AMediaCodec_infoOutputFormatChanged(FFAMediaCodec *codec, ssize_t idx)
Definition: mediacodec_wrapper.h:311
AVOption
AVOption.
Definition: opt.h:251
encode.h
ff_AMediaCodec_infoOutputBuffersChanged
static int ff_AMediaCodec_infoOutputBuffersChanged(FFAMediaCodec *codec, ssize_t idx)
Definition: mediacodec_wrapper.h:306
AV_HWDEVICE_TYPE_MEDIACODEC
@ AV_HWDEVICE_TYPE_MEDIACODEC
Definition: hwcontext.h:38
ff_AMediaCodec_queueInputBuffer
static int ff_AMediaCodec_queueInputBuffer(FFAMediaCodec *codec, size_t idx, off_t offset, size_t size, uint64_t time, uint32_t flags)
Definition: mediacodec_wrapper.h:276
AV_CODEC_HW_CONFIG_METHOD_AD_HOC
@ AV_CODEC_HW_CONFIG_METHOD_AD_HOC
The codec supports this format by some ad-hoc method.
Definition: codec.h:338
MediaCodecEncContext::eof_sent
int eof_sent
Definition: mediacodecenc.c:68
COMMON_OPTION
#define COMMON_OPTION
Definition: mediacodecenc.c:587
mediacodec_encode
static int mediacodec_encode(AVCodecContext *avctx, AVPacket *pkt)
Definition: mediacodecenc.c:505
FF_COMPLIANCE_EXPERIMENTAL
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition: defs.h:62
hwcontext_mediacodec.h
av_bsf_free
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
Definition: bsf.c:52
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:577
ff_AMediaFormat_setInt32
static void ff_AMediaFormat_setInt32(FFAMediaFormat *format, const char *name, int32_t value)
Definition: mediacodec_wrapper.h:135
AVBSFContext
The bitstream filter state.
Definition: bsf.h:68
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
VE
#define VE
Definition: mediacodecenc.c:586
AV_CODEC_FLAG_GLOBAL_HEADER
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
Definition: avcodec.h:338
mediacodec_output_format
static void mediacodec_output_format(AVCodecContext *avctx)
Definition: mediacodecenc.c:100
ff_AMediaCodec_configure
static int ff_AMediaCodec_configure(FFAMediaCodec *codec, const FFAMediaFormat *format, FFANativeWindow *surface, void *crypto, uint32_t flags)
Definition: mediacodec_wrapper.h:233
AV_PROFILE_H264_EXTENDED
#define AV_PROFILE_H264_EXTENDED
Definition: defs.h:112
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:1807
bsf.h
av1_options
static const AVOption av1_options[]
Definition: av1dec.c:1480
mediacodec_close
static av_cold int mediacodec_close(AVCodecContext *avctx)
Definition: mediacodecenc.c:552
MediaCodecEncContext::extradata
uint8_t * extradata
Definition: mediacodecenc.c:66
COLOR_FormatYUV420Planar
@ COLOR_FormatYUV420Planar
Definition: mediacodecenc.c:79
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:525
pix_fmt
enum AVPixelFormat pix_fmt
Definition: mediacodecenc.c:86
COLOR_RANGE_UNSPECIFIED
@ COLOR_RANGE_UNSPECIFIED
Definition: mediacodec_wrapper.h:349
AVERROR_BUFFER_TOO_SMALL
#define AVERROR_BUFFER_TOO_SMALL
Buffer too small.
Definition: error.h:53
pts
static int64_t pts
Definition: transcode_aac.c:643
AV_PROFILE_VP9_3
#define AV_PROFILE_VP9_3
Definition: defs.h:156
ff_AMediaFormat_new
FFAMediaFormat * ff_AMediaFormat_new(int ndk)
Definition: mediacodec_wrapper.c:2583
AVRational::num
int num
Numerator.
Definition: rational.h:59
mediacodecdec_common.h
mediacodec_receive
static int mediacodec_receive(AVCodecContext *avctx, AVPacket *pkt, int *got_packet)
Definition: mediacodecenc.c:351
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:62
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:88
mediacodec_send
static int mediacodec_send(AVCodecContext *avctx, const AVFrame *frame)
Definition: mediacodecenc.c:456
avassert.h
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:206
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
MediaCodecEncContext::bitrate_mode
int bitrate_mode
Definition: mediacodecenc.c:73
ff_AMediaCodec_getName
static char * ff_AMediaCodec_getName(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:224
ff_AMediaCodec_getBufferFlagEndOfStream
static int ff_AMediaCodec_getBufferFlagEndOfStream(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:321
s
#define s(width, name)
Definition: cbs_vp9.c:198
hevc_options
static const AVOption hevc_options[]
Definition: videotoolboxenc.c:2931
BITRATE_MODE_CQ
@ BITRATE_MODE_CQ
Definition: mediacodecenc.c:46
AVCodecContext::global_quality
int global_quality
Global quality for codecs which cannot change it per frame.
Definition: avcodec.h:511
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
AV_CODEC_ID_VP9
@ AV_CODEC_ID_VP9
Definition: codec_id.h:220
AV_PROFILE_H264_HIGH_10
#define AV_PROFILE_H264_HIGH_10
Definition: defs.h:114
FF_AVCTX_PROFILE_OPTION
#define FF_AVCTX_PROFILE_OPTION(name, description, type, value)
Definition: profiles.h:25
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
OFFSET
#define OFFSET(x)
Definition: mediacodecenc.c:585
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AVCodecHWConfig::pix_fmt
enum AVPixelFormat pix_fmt
For decoders, a hardware pixel format which that decoder may be able to decode to if suitable hardwar...
Definition: codec.h:350
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:79
AV_PROFILE_H264_HIGH_422
#define AV_PROFILE_H264_HIGH_422
Definition: defs.h:117
frame
static AVFrame * frame
Definition: demux_decode.c:54
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition: avcodec.h:455
MediaCodecEncContext::use_ndk_codec
int use_ndk_codec
Definition: mediacodecenc.c:58
AV_PIX_FMT_MEDIACODEC
@ AV_PIX_FMT_MEDIACODEC
hardware decoding through MediaCodec
Definition: pixfmt.h:320
ff_AMediaFormatColorStandard_from_AVColorSpace
int ff_AMediaFormatColorStandard_from_AVColorSpace(enum AVColorSpace color_space)
Map AVColorSpace to MediaFormat color standard.
Definition: mediacodec_wrapper.c:2708
OUTPUT_DEQUEUE_TIMEOUT_US
#define OUTPUT_DEQUEUE_TIMEOUT_US
Definition: mediacodecenc.c:42
ff_AMediaCodec_getOutputFormat
static FFAMediaFormat * ff_AMediaCodec_getOutputFormat(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:286
MediaCodecEncContext::level
int level
Definition: mediacodecenc.c:74
av_bsf_init
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Definition: bsf.c:149
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
ff_AMediaCodec_createCodecByName
FFAMediaCodec * ff_AMediaCodec_createCodecByName(const char *name, int ndk)
Definition: mediacodec_wrapper.c:2590
ff_AMediaFormatColorRange_from_AVColorRange
int ff_AMediaFormatColorRange_from_AVColorRange(enum AVColorRange color_range)
Map AVColorRange to MediaFormat color range.
Definition: mediacodec_wrapper.c:2691
NULL
#define NULL
Definition: coverity.c:32
FFAMediaCodecBufferInfo
Definition: mediacodec_wrapper.h:172
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:1043
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:283
av_bsf_receive_packet
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
Definition: bsf.c:230
FFAMediaCodecBufferInfo::size
int32_t size
Definition: mediacodec_wrapper.h:174
AVMediaCodecContext
This structure holds a reference to a android/view/Surface object that will be used as output by the ...
Definition: mediacodec.h:33
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:495
profiles.h
ff_AMediaCodec_createEncoderByType
FFAMediaCodec * ff_AMediaCodec_createEncoderByType(const char *mime_type, int ndk)
Definition: mediacodec_wrapper.c:2604
ff_AMediaCodec_stop
static int ff_AMediaCodec_stop(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:246
ff_mediacodec_surface_unref
int ff_mediacodec_surface_unref(FFANativeWindow *window, void *log_ctx)
Definition: mediacodec_surface.c:59
BITRATE_MODE_CBR_FD
@ BITRATE_MODE_CBR_FD
Definition: mediacodecenc.c:52
ff_AMediaCodec_getBufferFlagKeyFrame
static int ff_AMediaCodec_getBufferFlagKeyFrame(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:326
mpeg4_options
static const AVOption mpeg4_options[]
Definition: v4l2_m2m_enc.c:397
BITRATE_MODE_CBR
@ BITRATE_MODE_CBR
Definition: mediacodecenc.c:50
AV_PROFILE_HEVC_MAIN_10
#define AV_PROFILE_HEVC_MAIN_10
Definition: defs.h:159
index
int index
Definition: gxfenc.c:89
AVMediaCodecDeviceContext
MediaCodec details.
Definition: hwcontext_mediacodec.h:27
ff_AMediaFormat_toString
static char * ff_AMediaFormat_toString(FFAMediaFormat *format)
Definition: mediacodec_wrapper.h:97
color_formats
static const struct @120 color_formats[]
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
Definition: codec.h:309
AVCodecContext::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avcodec.h:567
AVCodecContext::gop_size
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
Definition: avcodec.h:647
h264_options
static const AVOption h264_options[]
Definition: h264dec.c:1098
codec_internal.h
av_bsf_send_packet
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
Definition: bsf.c:202
av_err2str
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:121
COLOR_TRANSFER_UNSPECIFIED
@ COLOR_TRANSFER_UNSPECIFIED
Definition: mediacodec_wrapper.h:363
avc_pix_fmts
static enum AVPixelFormat avc_pix_fmts[]
Definition: mediacodecenc.c:93
size
int size
Definition: twinvq_data.h:10344
av_reallocp
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Definition: mem.c:186
ff_AMediaFormatColorTransfer_from_AVColorTransfer
int ff_AMediaFormatColorTransfer_from_AVColorTransfer(enum AVColorTransferCharacteristic color_transfer)
Map AVColorTransferCharacteristic to MediaFormat color transfer.
Definition: mediacodec_wrapper.c:2736
AVCodecHWConfigInternal
Definition: hwconfig.h:25
MediaCodecEncContext::bsf
AVBSFContext * bsf
Definition: mediacodecenc.c:71
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:521
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
ff_AMediaCodecProfile_getProfileFromAVCodecContext
int ff_AMediaCodecProfile_getProfileFromAVCodecContext(AVCodecContext *avctx)
The following API around MediaCodec and MediaFormat is based on the NDK one provided by Google since ...
Definition: mediacodec_wrapper.c:303
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:528
MediaCodecEncContext::name
const char * name
Definition: mediacodecenc.c:59
COLOR_FormatSurface
@ COLOR_FormatSurface
Definition: mediacodecenc.c:81
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
MediaCodecEncContext::width
int width
Definition: mediacodecenc.c:63
FF_MPEG4_PROFILE_OPTS
#define FF_MPEG4_PROFILE_OPTS
Definition: profiles.h:40
ff_AMediaCodec_getConfigureFlagEncode
static int ff_AMediaCodec_getConfigureFlagEncode(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:331
MediaCodecEncContext::codec
FFAMediaCodec * codec
Definition: mediacodecenc.c:57
FFANativeWindow
Definition: mediacodec_surface.h:28
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
mediacodec_wrapper.h
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:515
COLOR_STANDARD_UNSPECIFIED
@ COLOR_STANDARD_UNSPECIFIED
Definition: mediacodec_wrapper.h:355
round
static av_always_inline av_const double round(double x)
Definition: libm.h:444
FFAMediaCodec
Definition: mediacodec_wrapper.h:181
MediaCodecEncContext::height
int height
Definition: mediacodecenc.c:64
MediaCodecEncContext::extradata_size
int extradata_size
Definition: mediacodecenc.c:67
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:226
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:622
FFAMediaCodecBufferInfo::flags
uint32_t flags
Definition: mediacodec_wrapper.h:176
AVCodecContext::hw_device_ctx
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
Definition: avcodec.h:1985
AVMediaCodecContext::surface
void * surface
android/view/Surface object reference.
Definition: mediacodec.h:38
ff_mediacodec_surface_ref
FFANativeWindow * ff_mediacodec_surface_ref(void *surface, void *native_window, void *log_ctx)
Definition: mediacodec_surface.c:30
MediaCodecEncContext::frame
AVFrame * frame
Definition: mediacodecenc.c:70
INPUT_DEQUEUE_TIMEOUT_US
#define INPUT_DEQUEUE_TIMEOUT_US
Definition: mediacodecenc.c:41
AVCodecContext::height
int height
Definition: avcodec.h:625
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:662
av_jni_get_java_vm
void * av_jni_get_java_vm(void *log_ctx)
Definition: jni.c:74
AVMediaCodecDeviceContext::native_window
void * native_window
Pointer to ANativeWindow.
Definition: hwcontext_mediacodec.h:45
FFAMediaCodecBufferInfo::presentationTimeUs
int64_t presentationTimeUs
Definition: mediacodec_wrapper.h:175
ff_AMediaCodec_dequeueInputBuffer
static ssize_t ff_AMediaCodec_dequeueInputBuffer(FFAMediaCodec *codec, int64_t timeoutUs)
Definition: mediacodec_wrapper.h:271
avcodec.h
AV_PROFILE_VP9_2
#define AV_PROFILE_VP9_2
Definition: defs.h:155
ret
ret
Definition: filter_design.txt:187
AVHWDeviceContext::type
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
Definition: hwcontext.h:80
AV_PIX_FMT_NV12
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:96
AVCodecContext::strict_std_compliance
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition: avcodec.h:1375
AV_PROFILE_H264_BASELINE
#define AV_PROFILE_H264_BASELINE
Definition: defs.h:109
av_mediacodec_release_buffer
int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render)
Release a MediaCodec buffer and render it to the surface that is associated with the decoder.
Definition: mediacodec.c:138
AVCodecContext
main external API structure.
Definition: avcodec.h:445
AV_PROFILE_H264_HIGH
#define AV_PROFILE_H264_HIGH
Definition: defs.h:113
mediacodec_init
static av_cold int mediacodec_init(AVCodecContext *avctx)
Definition: mediacodecenc.c:150
ff_get_encode_buffer
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
Definition: encode.c:105
av_image_copy2
static void av_image_copy2(uint8_t *const dst_data[4], const int dst_linesizes[4], uint8_t *const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Wrapper around av_image_copy() to workaround the limitation that the conversion from uint8_t * const ...
Definition: imgutils.h:184
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV_PROFILE_H264_CONSTRAINED_BASELINE
#define AV_PROFILE_H264_CONSTRAINED_BASELINE
Definition: defs.h:110
ff_AMediaCodec_getBufferFlagCodecConfig
static int ff_AMediaCodec_getBufferFlagCodecConfig(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:316
AV_PROFILE_VP9_0
#define AV_PROFILE_VP9_0
Definition: defs.h:153
av_bsf_list_parse_str
int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
Parse string describing list of bitstream filters and create single AVBSFContext describing the whole...
Definition: bsf.c:526
AV_PROFILE_H264_HIGH_444
#define AV_PROFILE_H264_HIGH_444
Definition: defs.h:120
AVCodecContext::max_b_frames
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
Definition: avcodec.h:724
ff_encode_get_frame
int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
Called by encoders to get the next frame for encoding.
Definition: encode.c:209
ff_AMediaCodec_getOutputBuffer
static uint8_t * ff_AMediaCodec_getOutputBuffer(FFAMediaCodec *codec, size_t idx, size_t *out_size)
Definition: mediacodec_wrapper.h:266
avcodec_parameters_from_context
int avcodec_parameters_from_context(struct AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
Definition: codec_par.c:137
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
ff_AMediaCodec_cleanOutputBuffers
static int ff_AMediaCodec_cleanOutputBuffers(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:336
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AVPacket
This structure stores compressed data.
Definition: packet.h:499
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
ff_AMediaCodec_infoTryAgainLater
static int ff_AMediaCodec_infoTryAgainLater(FFAMediaCodec *codec, ssize_t idx)
Definition: mediacodec_wrapper.h:301
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:625
imgutils.h
AV_CODEC_ID_VP8
@ AV_CODEC_ID_VP8
Definition: codec_id.h:192
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:385
ff_AMediaCodec_releaseOutputBuffer
static int ff_AMediaCodec_releaseOutputBuffer(FFAMediaCodec *codec, size_t idx, int render)
Definition: mediacodec_wrapper.h:291
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
jni.h
mediacodec_hw_configs
static const AVCodecHWConfigInternal *const mediacodec_hw_configs[]
Definition: mediacodecenc.c:572
AVCodecHWConfigInternal::public
AVCodecHWConfig public
This is the structure which will be returned to the user by avcodec_get_hw_config().
Definition: hwconfig.h:30
FFAMediaFormat
Definition: mediacodec_wrapper.h:63
ff_AMediaCodec_dequeueOutputBuffer
static ssize_t ff_AMediaCodec_dequeueOutputBuffer(FFAMediaCodec *codec, FFAMediaCodecBufferInfo *info, int64_t timeoutUs)
Definition: mediacodec_wrapper.h:281
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
snprintf
#define snprintf
Definition: snprintf.h:34
copy_frame_to_buffer
static void copy_frame_to_buffer(AVCodecContext *avctx, const AVFrame *frame, uint8_t *dst, size_t size)
Definition: mediacodecenc.c:429
COLOR_FormatYUV420SemiPlanar
@ COLOR_FormatYUV420SemiPlanar
Definition: mediacodecenc.c:80
mediacodec_init_bsf
static int mediacodec_init_bsf(AVCodecContext *avctx)
Definition: mediacodecenc.c:114
mediacodec.h