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/mem.h"
29 #include "libavutil/opt.h"
30 
31 #include "avcodec.h"
32 #include "bsf.h"
33 #include "codec_internal.h"
34 #include "encode.h"
35 #include "hwconfig.h"
36 #include "jni.h"
37 #include "mediacodec.h"
38 #include "mediacodec_wrapper.h"
39 #include "mediacodecdec_common.h"
40 #include "profiles.h"
41 
42 #define INPUT_DEQUEUE_TIMEOUT_US 8000
43 #define OUTPUT_DEQUEUE_TIMEOUT_US 8000
44 
46  /* Constant quality mode */
48  /* Variable bitrate mode */
50  /* Constant bitrate mode */
52  /* Constant bitrate mode with frame drops */
54 };
55 
56 typedef struct MediaCodecEncContext {
60  const char *name;
62 
63  int fps;
64  int width;
65  int height;
66 
67  uint8_t *extradata;
69  int eof_sent;
70 
73 
75  int level;
78 
79 enum {
82  COLOR_FormatSurface = 0x7F000789,
83 };
84 
85 static const struct {
88 } color_formats[] = {
92 };
93 
94 static const enum AVPixelFormat avc_pix_fmts[] = {
99 };
100 
102 {
103  MediaCodecEncContext *s = avctx->priv_data;
104  char *name = ff_AMediaCodec_getName(s->codec);
105  FFAMediaFormat *out_format = ff_AMediaCodec_getOutputFormat(s->codec);
106  char *str = ff_AMediaFormat_toString(out_format);
107 
108  av_log(avctx, AV_LOG_DEBUG, "MediaCodec encoder %s output format %s\n",
109  name ? name : "unknown", str);
110  av_free(name);
111  av_free(str);
112  ff_AMediaFormat_delete(out_format);
113 }
114 
116 {
117  MediaCodecEncContext *s = avctx->priv_data;
118  char str[128];
119  int ret;
120  int crop_right = s->width - avctx->width;
121  int crop_bottom = s->height - avctx->height;
122 
123  if (!crop_right && !crop_bottom)
124  return 0;
125 
126  if (avctx->codec_id == AV_CODEC_ID_H264)
127  ret = snprintf(str, sizeof(str), "h264_metadata=crop_right=%d:crop_bottom=%d",
128  crop_right, crop_bottom);
129  else if (avctx->codec_id == AV_CODEC_ID_HEVC)
130  ret = snprintf(str, sizeof(str), "hevc_metadata=crop_right=%d:crop_bottom=%d",
131  crop_right, crop_bottom);
132  else
133  return 0;
134 
135  if (ret >= sizeof(str))
137 
138  ret = av_bsf_list_parse_str(str, &s->bsf);
139  if (ret < 0)
140  return ret;
141 
142  ret = avcodec_parameters_from_context(s->bsf->par_in, avctx);
143  if (ret < 0)
144  return ret;
145  s->bsf->time_base_in = avctx->time_base;
146  ret = av_bsf_init(s->bsf);
147 
148  return ret;
149 }
150 
152 {
153  const char *codec_mime = NULL;
154  MediaCodecEncContext *s = avctx->priv_data;
156  int ret;
157  int gop;
158 
159  if (s->use_ndk_codec < 0)
160  s->use_ndk_codec = !av_jni_get_java_vm(avctx);
161 
162  switch (avctx->codec_id) {
163  case AV_CODEC_ID_H264:
164  codec_mime = "video/avc";
165  break;
166  case AV_CODEC_ID_HEVC:
167  codec_mime = "video/hevc";
168  break;
169  case AV_CODEC_ID_VP8:
170  codec_mime = "video/x-vnd.on2.vp8";
171  break;
172  case AV_CODEC_ID_VP9:
173  codec_mime = "video/x-vnd.on2.vp9";
174  break;
175  case AV_CODEC_ID_MPEG4:
176  codec_mime = "video/mp4v-es";
177  break;
178  case AV_CODEC_ID_AV1:
179  codec_mime = "video/av01";
180  break;
181  default:
182  av_assert0(0);
183  }
184 
185  if (s->name)
186  s->codec = ff_AMediaCodec_createCodecByName(s->name, s->use_ndk_codec);
187  else
188  s->codec = ff_AMediaCodec_createEncoderByType(codec_mime, s->use_ndk_codec);
189  if (!s->codec) {
190  av_log(avctx, AV_LOG_ERROR, "Failed to create encoder for type %s\n",
191  codec_mime);
192  return AVERROR_EXTERNAL;
193  }
194 
195  format = ff_AMediaFormat_new(s->use_ndk_codec);
196  if (!format) {
197  av_log(avctx, AV_LOG_ERROR, "Failed to create media format\n");
198  return AVERROR_EXTERNAL;
199  }
200 
201  ff_AMediaFormat_setString(format, "mime", codec_mime);
202  // Workaround the alignment requirement of mediacodec. We can't do it
203  // silently for AV_PIX_FMT_MEDIACODEC.
204  if (avctx->pix_fmt != AV_PIX_FMT_MEDIACODEC) {
205  s->width = FFALIGN(avctx->width, 16);
206  s->height = FFALIGN(avctx->height, 16);
207  } else {
208  s->width = avctx->width;
209  s->height = avctx->height;
210  if (s->width % 16 || s->height % 16)
211  av_log(avctx, AV_LOG_WARNING,
212  "Video size %dx%d isn't align to 16, it may have device compatibility issue\n",
213  s->width, s->height);
214  }
215  ff_AMediaFormat_setInt32(format, "width", s->width);
216  ff_AMediaFormat_setInt32(format, "height", s->height);
217 
218  if (avctx->pix_fmt == AV_PIX_FMT_MEDIACODEC) {
219  AVMediaCodecContext *user_ctx = avctx->hwaccel_context;
220  if (avctx->hw_device_ctx) {
221  AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)(avctx->hw_device_ctx->data);
222  AVMediaCodecDeviceContext *dev_ctx;
223 
224  if (device_ctx->type != AV_HWDEVICE_TYPE_MEDIACODEC || !device_ctx->hwctx) {
225  ret = AVERROR(EINVAL);
226  goto bailout;
227  }
228  dev_ctx = device_ctx->hwctx;
229  s->window = ff_mediacodec_surface_ref(dev_ctx->surface, dev_ctx->native_window, avctx);
230  }
231 
232  if (!s->window && user_ctx && user_ctx->surface)
233  s->window = ff_mediacodec_surface_ref(user_ctx->surface, NULL, avctx);
234 
235  if (!s->window) {
236  ret = AVERROR(EINVAL);
237  av_log(avctx, AV_LOG_ERROR, "Missing hw_device_ctx or hwaccel_context for AV_PIX_FMT_MEDIACODEC\n");
238  goto bailout;
239  }
240  /* Although there is a method ANativeWindow_toSurface() introduced in
241  * API level 26, it's easier and safe to always require a Surface for
242  * Java MediaCodec.
243  */
244  if (!s->use_ndk_codec && !s->window->surface) {
245  ret = AVERROR(EINVAL);
246  av_log(avctx, AV_LOG_ERROR, "Missing jobject Surface for AV_PIX_FMT_MEDIACODEC. "
247  "Please note that Java MediaCodec doesn't work with ANativeWindow.\n");
248  goto bailout;
249  }
250  }
251 
252  for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
253  if (avctx->pix_fmt == color_formats[i].pix_fmt) {
254  ff_AMediaFormat_setInt32(format, "color-format",
256  break;
257  }
258  }
259 
262  ff_AMediaFormat_setInt32(format, "color-range", ret);
265  ff_AMediaFormat_setInt32(format, "color-standard", ret);
268  ff_AMediaFormat_setInt32(format, "color-transfer", ret);
269 
270  if (avctx->bit_rate)
271  ff_AMediaFormat_setInt32(format, "bitrate", avctx->bit_rate);
272  if (s->bitrate_mode >= 0) {
273  ff_AMediaFormat_setInt32(format, "bitrate-mode", s->bitrate_mode);
274  if (s->bitrate_mode == BITRATE_MODE_CQ && avctx->global_quality > 0)
275  ff_AMediaFormat_setInt32(format, "quality", avctx->global_quality);
276  }
277  // frame-rate and i-frame-interval are required to configure codec
278  if (avctx->framerate.num >= avctx->framerate.den && avctx->framerate.den > 0) {
279  s->fps = avctx->framerate.num / avctx->framerate.den;
280  } else {
281  s->fps = 30;
282  av_log(avctx, AV_LOG_INFO, "Use %d as the default MediaFormat frame-rate\n", s->fps);
283  }
284  gop = round(avctx->gop_size / s->fps);
285  if (gop == 0) {
286  gop = 1;
287  av_log(avctx, AV_LOG_INFO,
288  "Use %d as the default MediaFormat i-frame-interval, "
289  "please set gop_size properly (>= fps)\n", gop);
290  } else {
291  av_log(avctx, AV_LOG_DEBUG, "Set i-frame-interval to %d\n", gop);
292  }
293 
294  ff_AMediaFormat_setInt32(format, "frame-rate", s->fps);
295  ff_AMediaFormat_setInt32(format, "i-frame-interval", gop);
296 
298  if (ret > 0) {
299  av_log(avctx, AV_LOG_DEBUG, "set profile to 0x%x\n", ret);
300  ff_AMediaFormat_setInt32(format, "profile", ret);
301  }
302  if (s->level > 0) {
303  av_log(avctx, AV_LOG_DEBUG, "set level to 0x%x\n", s->level);
304  ff_AMediaFormat_setInt32(format, "level", s->level);
305  }
306  if (avctx->max_b_frames > 0) {
308  av_log(avctx, AV_LOG_ERROR,
309  "Enabling B frames will produce packets with no DTS. "
310  "Use -strict experimental to use it anyway.\n");
311  ret = AVERROR(EINVAL);
312  goto bailout;
313  }
314  ff_AMediaFormat_setInt32(format, "max-bframes", avctx->max_b_frames);
315  }
316  if (s->pts_as_dts == -1)
317  s->pts_as_dts = avctx->max_b_frames <= 0;
318 
320  ret = ff_AMediaCodec_configure(s->codec, format, s->window, NULL, ret);
321  if (ret) {
322  av_log(avctx, AV_LOG_ERROR, "MediaCodec configure failed, %s\n", av_err2str(ret));
323  if (avctx->pix_fmt == AV_PIX_FMT_YUV420P)
324  av_log(avctx, AV_LOG_ERROR, "Please try -pix_fmt nv12, some devices don't "
325  "support yuv420p as encoder input format.\n");
326  goto bailout;
327  }
328 
329  ret = ff_AMediaCodec_start(s->codec);
330  if (ret) {
331  av_log(avctx, AV_LOG_ERROR, "MediaCodec failed to start, %s\n", av_err2str(ret));
332  goto bailout;
333  }
334 
335  ret = mediacodec_init_bsf(avctx);
336  if (ret)
337  goto bailout;
338 
340  if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)
341  av_log(avctx, AV_LOG_WARNING,
342  "Mediacodec encoder doesn't support AV_CODEC_FLAG_GLOBAL_HEADER. "
343  "Use extract_extradata bsf when necessary.\n");
344 
345  s->frame = av_frame_alloc();
346  if (!s->frame)
347  ret = AVERROR(ENOMEM);
348 
349 bailout:
350  if (format)
352  return ret;
353 }
354 
356  AVPacket *pkt,
357  int *got_packet)
358 {
359  MediaCodecEncContext *s = avctx->priv_data;
360  FFAMediaCodec *codec = s->codec;
361  FFAMediaCodecBufferInfo out_info = {0};
362  uint8_t *out_buf;
363  size_t out_size = 0;
364  int ret;
365  int extradata_size = 0;
366  int64_t timeout_us = s->eof_sent ? OUTPUT_DEQUEUE_TIMEOUT_US : 0;
367  ssize_t index = ff_AMediaCodec_dequeueOutputBuffer(codec, &out_info, timeout_us);
368 
370  return AVERROR(EAGAIN);
371 
374  return AVERROR(EAGAIN);
375  }
376 
379  return AVERROR(EAGAIN);
380  }
381 
382  if (index < 0)
383  return AVERROR_EXTERNAL;
384 
385  if (out_info.flags & ff_AMediaCodec_getBufferFlagEndOfStream(codec))
386  return AVERROR_EOF;
387 
388  out_buf = ff_AMediaCodec_getOutputBuffer(codec, index, &out_size);
389  if (!out_buf) {
391  goto bailout;
392  }
393 
394  if (out_info.flags & ff_AMediaCodec_getBufferFlagCodecConfig(codec)) {
395  ret = av_reallocp(&s->extradata, out_info.size);
396  if (ret)
397  goto bailout;
398 
399  s->extradata_size = out_info.size;
400  memcpy(s->extradata, out_buf + out_info.offset, out_info.size);
402  // try immediately
403  return mediacodec_receive(avctx, pkt, got_packet);
404  }
405 
406  ret = ff_get_encode_buffer(avctx, pkt, out_info.size + s->extradata_size, 0);
407  if (ret < 0)
408  goto bailout;
409 
410  if (s->extradata_size) {
411  extradata_size = s->extradata_size;
412  s->extradata_size = 0;
413  memcpy(pkt->data, s->extradata, extradata_size);
414  }
415  memcpy(pkt->data + extradata_size, out_buf + out_info.offset, out_info.size);
417  if (s->pts_as_dts)
418  pkt->dts = pkt->pts;
419  if (out_info.flags & ff_AMediaCodec_getBufferFlagKeyFrame(codec))
421  ret = 0;
422  *got_packet = 1;
423 
424  av_log(avctx, AV_LOG_TRACE, "receive packet pts %" PRId64 " dts %" PRId64
425  " flags %d extradata %d\n",
426  pkt->pts, pkt->dts, pkt->flags, extradata_size);
427 
428 bailout:
430  return ret;
431 }
432 
433 static void copy_frame_to_buffer(AVCodecContext *avctx, const AVFrame *frame, uint8_t *dst, size_t size)
434 {
435  MediaCodecEncContext *s = avctx->priv_data;
436  uint8_t *dst_data[4] = {};
437  int dst_linesize[4] = {};
438 
439  if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) {
440  dst_data[0] = dst;
441  dst_data[1] = dst + s->width * s->height;
442  dst_data[2] = dst_data[1] + s->width * s->height / 4;
443 
444  dst_linesize[0] = s->width;
445  dst_linesize[1] = dst_linesize[2] = s->width / 2;
446  } else if (avctx->pix_fmt == AV_PIX_FMT_NV12) {
447  dst_data[0] = dst;
448  dst_data[1] = dst + s->width * s->height;
449 
450  dst_linesize[0] = s->width;
451  dst_linesize[1] = s->width;
452  } else {
453  av_assert0(0);
454  }
455 
456  av_image_copy2(dst_data, dst_linesize, frame->data, frame->linesize,
457  avctx->pix_fmt, avctx->width, avctx->height);
458 }
459 
460 static int mediacodec_send(AVCodecContext *avctx,
461  const AVFrame *frame) {
462  MediaCodecEncContext *s = avctx->priv_data;
463  FFAMediaCodec *codec = s->codec;
464  ssize_t index;
465  uint8_t *input_buf = NULL;
466  size_t input_size = 0;
467  int64_t pts = 0;
468  uint32_t flags = 0;
469  int64_t timeout_us;
470 
471  if (s->eof_sent)
472  return 0;
473 
474  if (s->window) {
475  if (!frame) {
476  s->eof_sent = 1;
478  }
479 
480  if (frame->data[3])
481  av_mediacodec_release_buffer((AVMediaCodecBuffer *)frame->data[3], 1);
482  return 0;
483  }
484 
485  timeout_us = INPUT_DEQUEUE_TIMEOUT_US;
486  index = ff_AMediaCodec_dequeueInputBuffer(codec, timeout_us);
488  return AVERROR(EAGAIN);
489 
490  if (index < 0) {
491  av_log(avctx, AV_LOG_ERROR, "dequeue input buffer failed, %zd", index);
492  return AVERROR_EXTERNAL;
493  }
494 
495  if (frame) {
496  input_buf = ff_AMediaCodec_getInputBuffer(codec, index, &input_size);
497  copy_frame_to_buffer(avctx, frame, input_buf, input_size);
498 
499  pts = av_rescale_q(frame->pts, avctx->time_base, AV_TIME_BASE_Q);
500  } else {
502  s->eof_sent = 1;
503  }
504 
505  ff_AMediaCodec_queueInputBuffer(codec, index, 0, input_size, pts, flags);
506  return 0;
507 }
508 
510 {
511  MediaCodecEncContext *s = avctx->priv_data;
512  int ret;
513  int got_packet = 0;
514 
515  // Return on three case:
516  // 1. Serious error
517  // 2. Got a packet success
518  // 3. No AVFrame is available yet (don't return if get_frame return EOF)
519  while (1) {
520  if (s->bsf) {
521  ret = av_bsf_receive_packet(s->bsf, pkt);
522  if (!ret)
523  return 0;
524  if (ret != AVERROR(EAGAIN))
525  return ret;
526  }
527 
528  ret = mediacodec_receive(avctx, pkt, &got_packet);
529  if (s->bsf) {
530  if (!ret || ret == AVERROR_EOF)
531  ret = av_bsf_send_packet(s->bsf, pkt);
532  } else {
533  if (!ret)
534  return 0;
535  }
536 
537  if (ret != AVERROR(EAGAIN))
538  return ret;
539 
540  if (!s->frame->buf[0]) {
541  ret = ff_encode_get_frame(avctx, s->frame);
542  if (ret && ret != AVERROR_EOF)
543  return ret;
544  }
545 
546  ret = mediacodec_send(avctx, s->frame->buf[0] ? s->frame : NULL);
547  if (!ret)
548  av_frame_unref(s->frame);
549  else if (ret != AVERROR(EAGAIN))
550  return ret;
551  }
552 
553  return 0;
554 }
555 
557 {
558  MediaCodecEncContext *s = avctx->priv_data;
559  if (s->codec) {
560  ff_AMediaCodec_stop(s->codec);
561  ff_AMediaCodec_delete(s->codec);
562  s->codec = NULL;
563  }
564 
565  if (s->window) {
566  ff_mediacodec_surface_unref(s->window, avctx);
567  s->window = NULL;
568  }
569 
570  av_bsf_free(&s->bsf);
571  av_frame_free(&s->frame);
572 
573  return 0;
574 }
575 
577  &(const AVCodecHWConfigInternal) {
578  .public = {
582  .device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
583  },
584  .hwaccel = NULL,
585  },
586  NULL
587 };
588 
589 #define OFFSET(x) offsetof(MediaCodecEncContext, x)
590 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
591 #define COMMON_OPTION \
592  { "ndk_codec", "Use MediaCodec from NDK", \
593  OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, \
594  { "codec_name", "Select codec by name", \
595  OFFSET(name), AV_OPT_TYPE_STRING, {0}, 0, 0, VE }, \
596  { "bitrate_mode", "Bitrate control method", \
597  OFFSET(bitrate_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, .unit = "bitrate_mode" }, \
598  { "cq", "Constant quality mode", \
599  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CQ}, 0, 0, VE, .unit = "bitrate_mode" }, \
600  { "vbr", "Variable bitrate mode", \
601  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_VBR}, 0, 0, VE, .unit = "bitrate_mode" }, \
602  { "cbr", "Constant bitrate mode", \
603  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CBR}, 0, 0, VE, .unit = "bitrate_mode" }, \
604  { "cbr_fd", "Constant bitrate mode with frame drops", \
605  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CBR_FD}, 0, 0, VE, .unit = "bitrate_mode" }, \
606  { "pts_as_dts", "Use PTS as DTS. It is enabled automatically if avctx max_b_frames <= 0, " \
607  "since most of Android devices don't output B frames by default.", \
608  OFFSET(pts_as_dts), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, \
609 
610 
611 #define MEDIACODEC_ENCODER_CLASS(name) \
612 static const AVClass name ## _mediacodec_class = { \
613  .class_name = #name "_mediacodec", \
614  .item_name = av_default_item_name, \
615  .option = name ## _options, \
616  .version = LIBAVUTIL_VERSION_INT, \
617 }; \
618 
619 #define DECLARE_MEDIACODEC_ENCODER(short_name, long_name, codec_id) \
620 MEDIACODEC_ENCODER_CLASS(short_name) \
621 const FFCodec ff_ ## short_name ## _mediacodec_encoder = { \
622  .p.name = #short_name "_mediacodec", \
623  CODEC_LONG_NAME(long_name " Android MediaCodec encoder"), \
624  .p.type = AVMEDIA_TYPE_VIDEO, \
625  .p.id = codec_id, \
626  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY \
627  | AV_CODEC_CAP_HARDWARE, \
628  .priv_data_size = sizeof(MediaCodecEncContext), \
629  .p.pix_fmts = avc_pix_fmts, \
630  .init = mediacodec_init, \
631  FF_CODEC_RECEIVE_PACKET_CB(mediacodec_encode), \
632  .close = mediacodec_close, \
633  .p.priv_class = &short_name ## _mediacodec_class, \
634  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \
635  .p.wrapper_name = "mediacodec", \
636  .hw_configs = mediacodec_hw_configs, \
637 }; \
638 
639 #if CONFIG_H264_MEDIACODEC_ENCODER
640 
641 enum MediaCodecAvcLevel {
642  AVCLevel1 = 0x01,
643  AVCLevel1b = 0x02,
644  AVCLevel11 = 0x04,
645  AVCLevel12 = 0x08,
646  AVCLevel13 = 0x10,
647  AVCLevel2 = 0x20,
648  AVCLevel21 = 0x40,
649  AVCLevel22 = 0x80,
650  AVCLevel3 = 0x100,
651  AVCLevel31 = 0x200,
652  AVCLevel32 = 0x400,
653  AVCLevel4 = 0x800,
654  AVCLevel41 = 0x1000,
655  AVCLevel42 = 0x2000,
656  AVCLevel5 = 0x4000,
657  AVCLevel51 = 0x8000,
658  AVCLevel52 = 0x10000,
659  AVCLevel6 = 0x20000,
660  AVCLevel61 = 0x40000,
661  AVCLevel62 = 0x80000,
662 };
663 
664 static const AVOption h264_options[] = {
666 
668  FF_AVCTX_PROFILE_OPTION("constrained_baseline", NULL, VIDEO, AV_PROFILE_H264_CONSTRAINED_BASELINE)
675 
676  { "level", "Specify level",
677  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
678  { "1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel1 }, 0, 0, VE, .unit = "level" },
679  { "1b", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel1b }, 0, 0, VE, .unit = "level" },
680  { "1.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel11 }, 0, 0, VE, .unit = "level" },
681  { "1.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel12 }, 0, 0, VE, .unit = "level" },
682  { "1.3", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel13 }, 0, 0, VE, .unit = "level" },
683  { "2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel2 }, 0, 0, VE, .unit = "level" },
684  { "2.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel21 }, 0, 0, VE, .unit = "level" },
685  { "2.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel22 }, 0, 0, VE, .unit = "level" },
686  { "3", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel3 }, 0, 0, VE, .unit = "level" },
687  { "3.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel31 }, 0, 0, VE, .unit = "level" },
688  { "3.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel32 }, 0, 0, VE, .unit = "level" },
689  { "4", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel4 }, 0, 0, VE, .unit = "level" },
690  { "4.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel41 }, 0, 0, VE, .unit = "level" },
691  { "4.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel42 }, 0, 0, VE, .unit = "level" },
692  { "5", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel5 }, 0, 0, VE, .unit = "level" },
693  { "5.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel51 }, 0, 0, VE, .unit = "level" },
694  { "5.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel52 }, 0, 0, VE, .unit = "level" },
695  { "6.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel6 }, 0, 0, VE, .unit = "level" },
696  { "6.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel61 }, 0, 0, VE, .unit = "level" },
697  { "6.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel62 }, 0, 0, VE, .unit = "level" },
698  { NULL, }
699 };
700 
702 
703 #endif // CONFIG_H264_MEDIACODEC_ENCODER
704 
705 #if CONFIG_HEVC_MEDIACODEC_ENCODER
706 
707 enum MediaCodecHevcLevel {
708  HEVCMainTierLevel1 = 0x1,
709  HEVCHighTierLevel1 = 0x2,
710  HEVCMainTierLevel2 = 0x4,
711  HEVCHighTierLevel2 = 0x8,
712  HEVCMainTierLevel21 = 0x10,
713  HEVCHighTierLevel21 = 0x20,
714  HEVCMainTierLevel3 = 0x40,
715  HEVCHighTierLevel3 = 0x80,
716  HEVCMainTierLevel31 = 0x100,
717  HEVCHighTierLevel31 = 0x200,
718  HEVCMainTierLevel4 = 0x400,
719  HEVCHighTierLevel4 = 0x800,
720  HEVCMainTierLevel41 = 0x1000,
721  HEVCHighTierLevel41 = 0x2000,
722  HEVCMainTierLevel5 = 0x4000,
723  HEVCHighTierLevel5 = 0x8000,
724  HEVCMainTierLevel51 = 0x10000,
725  HEVCHighTierLevel51 = 0x20000,
726  HEVCMainTierLevel52 = 0x40000,
727  HEVCHighTierLevel52 = 0x80000,
728  HEVCMainTierLevel6 = 0x100000,
729  HEVCHighTierLevel6 = 0x200000,
730  HEVCMainTierLevel61 = 0x400000,
731  HEVCHighTierLevel61 = 0x800000,
732  HEVCMainTierLevel62 = 0x1000000,
733  HEVCHighTierLevel62 = 0x2000000,
734 };
735 
736 static const AVOption hevc_options[] = {
738 
741 
742  { "level", "Specify tier and level",
743  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
744  { "m1", "Main tier level 1",
745  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel1 }, 0, 0, VE, .unit = "level" },
746  { "h1", "High tier level 1",
747  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel1 }, 0, 0, VE, .unit = "level" },
748  { "m2", "Main tier level 2",
749  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel2 }, 0, 0, VE, .unit = "level" },
750  { "h2", "High tier level 2",
751  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel2 }, 0, 0, VE, .unit = "level" },
752  { "m2.1", "Main tier level 2.1",
753  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel21 }, 0, 0, VE, .unit = "level" },
754  { "h2.1", "High tier level 2.1",
755  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel21 }, 0, 0, VE, .unit = "level" },
756  { "m3", "Main tier level 3",
757  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel3 }, 0, 0, VE, .unit = "level" },
758  { "h3", "High tier level 3",
759  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel3 }, 0, 0, VE, .unit = "level" },
760  { "m3.1", "Main tier level 3.1",
761  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel31 }, 0, 0, VE, .unit = "level" },
762  { "h3.1", "High tier level 3.1",
763  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel31 }, 0, 0, VE, .unit = "level" },
764  { "m4", "Main tier level 4",
765  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel4 }, 0, 0, VE, .unit = "level" },
766  { "h4", "High tier level 4",
767  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel4 }, 0, 0, VE, .unit = "level" },
768  { "m4.1", "Main tier level 4.1",
769  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel41 }, 0, 0, VE, .unit = "level" },
770  { "h4.1", "High tier level 4.1",
771  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel41 }, 0, 0, VE, .unit = "level" },
772  { "m5", "Main tier level 5",
773  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel5 }, 0, 0, VE, .unit = "level" },
774  { "h5", "High tier level 5",
775  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel5 }, 0, 0, VE, .unit = "level" },
776  { "m5.1", "Main tier level 5.1",
777  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel51 }, 0, 0, VE, .unit = "level" },
778  { "h5.1", "High tier level 5.1",
779  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel51 }, 0, 0, VE, .unit = "level" },
780  { "m5.2", "Main tier level 5.2",
781  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel52 }, 0, 0, VE, .unit = "level" },
782  { "h5.2", "High tier level 5.2",
783  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel52 }, 0, 0, VE, .unit = "level" },
784  { "m6", "Main tier level 6",
785  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel6 }, 0, 0, VE, .unit = "level" },
786  { "h6", "High tier level 6",
787  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel6 }, 0, 0, VE, .unit = "level" },
788  { "m6.1", "Main tier level 6.1",
789  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel61 }, 0, 0, VE, .unit = "level" },
790  { "h6.1", "High tier level 6.1",
791  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel61 }, 0, 0, VE, .unit = "level" },
792  { "m6.2", "Main tier level 6.2",
793  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel62 }, 0, 0, VE, .unit = "level" },
794  { "h6.2", "High tier level 6.2",
795  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel62 }, 0, 0, VE, .unit = "level" },
796  { NULL, }
797 };
798 
800 
801 #endif // CONFIG_HEVC_MEDIACODEC_ENCODER
802 
803 #if CONFIG_VP8_MEDIACODEC_ENCODER
804 
805 enum MediaCodecVP8Level {
806  VP8Level_Version0 = 0x01,
807  VP8Level_Version1 = 0x02,
808  VP8Level_Version2 = 0x04,
809  VP8Level_Version3 = 0x08,
810 };
811 
812 static const AVOption vp8_options[] = {
814  { "level", "Specify tier and level",
815  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
816  { "V0", "Level Version 0",
817  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version0 }, 0, 0, VE, .unit = "level" },
818  { "V1", "Level Version 1",
819  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version1 }, 0, 0, VE, .unit = "level" },
820  { "V2", "Level Version 2",
821  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version2 }, 0, 0, VE, .unit = "level" },
822  { "V3", "Level Version 3",
823  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version3 }, 0, 0, VE, .unit = "level" },
824  { NULL, }
825 };
826 
828 
829 #endif // CONFIG_VP8_MEDIACODEC_ENCODER
830 
831 #if CONFIG_VP9_MEDIACODEC_ENCODER
832 
833 enum MediaCodecVP9Level {
834  VP9Level1 = 0x1,
835  VP9Level11 = 0x2,
836  VP9Level2 = 0x4,
837  VP9Level21 = 0x8,
838  VP9Level3 = 0x10,
839  VP9Level31 = 0x20,
840  VP9Level4 = 0x40,
841  VP9Level41 = 0x80,
842  VP9Level5 = 0x100,
843  VP9Level51 = 0x200,
844  VP9Level52 = 0x400,
845  VP9Level6 = 0x800,
846  VP9Level61 = 0x1000,
847  VP9Level62 = 0x2000,
848 };
849 
850 static const AVOption vp9_options[] = {
852 
853  FF_AVCTX_PROFILE_OPTION("profile0", NULL, VIDEO, AV_PROFILE_VP9_0)
854  FF_AVCTX_PROFILE_OPTION("profile1", NULL, VIDEO, AV_PROFILE_VP9_1)
855  FF_AVCTX_PROFILE_OPTION("profile2", NULL, VIDEO, AV_PROFILE_VP9_2)
856  FF_AVCTX_PROFILE_OPTION("profile3", NULL, VIDEO, AV_PROFILE_VP9_3)
857 
858  { "level", "Specify tier and level",
859  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
860  { "1", "Level 1",
861  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level1 }, 0, 0, VE, .unit = "level" },
862  { "1.1", "Level 1.1",
863  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level11 }, 0, 0, VE, .unit = "level" },
864  { "2", "Level 2",
865  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level2 }, 0, 0, VE, .unit = "level" },
866  { "2.1", "Level 2.1",
867  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level21 }, 0, 0, VE, .unit = "level" },
868  { "3", "Level 3",
869  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level3 }, 0, 0, VE, .unit = "level" },
870  { "3.1", "Level 3.1",
871  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level31 }, 0, 0, VE, .unit = "level" },
872  { "4", "Level 4",
873  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level4 }, 0, 0, VE, .unit = "level" },
874  { "4.1", "Level 4.1",
875  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level41 }, 0, 0, VE, .unit = "level" },
876  { "5", "Level 5",
877  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level5 }, 0, 0, VE, .unit = "level" },
878  { "5.1", "Level 5.1",
879  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level51 }, 0, 0, VE, .unit = "level" },
880  { "5.2", "Level 5.2",
881  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level52 }, 0, 0, VE, .unit = "level" },
882  { "6", "Level 6",
883  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level6 }, 0, 0, VE, .unit = "level" },
884  { "6.1", "Level 4.1",
885  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level61 }, 0, 0, VE, .unit = "level" },
886  { "6.2", "Level 6.2",
887  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level62 }, 0, 0, VE, .unit = "level" },
888  { NULL, }
889 };
890 
892 
893 #endif // CONFIG_VP9_MEDIACODEC_ENCODER
894 
895 #if CONFIG_MPEG4_MEDIACODEC_ENCODER
896 
897 enum MediaCodecMpeg4Level {
898  MPEG4Level0 = 0x01,
899  MPEG4Level0b = 0x02,
900  MPEG4Level1 = 0x04,
901  MPEG4Level2 = 0x08,
902  MPEG4Level3 = 0x10,
903  MPEG4Level3b = 0x18,
904  MPEG4Level4 = 0x20,
905  MPEG4Level4a = 0x40,
906  MPEG4Level5 = 0x80,
907  MPEG4Level6 = 0x100,
908 };
909 
910 static const AVOption mpeg4_options[] = {
912 
914 
915  { "level", "Specify tier and level",
916  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
917  { "0", "Level 0",
918  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level0 }, 0, 0, VE, .unit = "level" },
919  { "0b", "Level 0b",
920  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level0b }, 0, 0, VE, .unit = "level" },
921  { "1", "Level 1",
922  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level1 }, 0, 0, VE, .unit = "level" },
923  { "2", "Level 2",
924  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level2 }, 0, 0, VE, .unit = "level" },
925  { "3", "Level 3",
926  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level3 }, 0, 0, VE, .unit = "level" },
927  { "3b", "Level 3b",
928  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level3b }, 0, 0, VE, .unit = "level" },
929  { "4", "Level 4",
930  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level4 }, 0, 0, VE, .unit = "level" },
931  { "4a", "Level 4a",
932  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level4a }, 0, 0, VE, .unit = "level" },
933  { "5", "Level 5",
934  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level5 }, 0, 0, VE, .unit = "level" },
935  { "6", "Level 6",
936  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level6 }, 0, 0, VE, .unit = "level" },
937  { NULL, }
938 };
939 
941 
942 #endif // CONFIG_MPEG4_MEDIACODEC_ENCODER
943 
944 #if CONFIG_AV1_MEDIACODEC_ENCODER
945 
946 enum MediaCodecAV1Level {
947  AV1Level2 = 0x1,
948  AV1Level21 = 0x2,
949  AV1Level22 = 0x4,
950  AV1Level23 = 0x8,
951  AV1Level3 = 0x10,
952  AV1Level31 = 0x20,
953  AV1Level32 = 0x40,
954  AV1Level33 = 0x80,
955  AV1Level4 = 0x100,
956  AV1Level41 = 0x200,
957  AV1Level42 = 0x400,
958  AV1Level43 = 0x800,
959  AV1Level5 = 0x1000,
960  AV1Level51 = 0x2000,
961  AV1Level52 = 0x4000,
962  AV1Level53 = 0x8000,
963  AV1Level6 = 0x10000,
964  AV1Level61 = 0x20000,
965  AV1Level62 = 0x40000,
966  AV1Level63 = 0x80000,
967  AV1Level7 = 0x100000,
968  AV1Level71 = 0x200000,
969  AV1Level72 = 0x400000,
970  AV1Level73 = 0x800000,
971 };
972 
973 static const AVOption av1_options[] = {
975 
977 
978  { "level", "Specify tier and level",
979  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
980  { "2", "Level 2",
981  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level2 }, 0, 0, VE, .unit = "level" },
982  { "2.1", "Level 2.1",
983  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level21 }, 0, 0, VE, .unit = "level" },
984  { "2.2", "Level 2.2",
985  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level22 }, 0, 0, VE, .unit = "level" },
986  { "2.3", "Level 2.3",
987  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level23 }, 0, 0, VE, .unit = "level" },
988  { "3", "Level 3",
989  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level3 }, 0, 0, VE, .unit = "level" },
990  { "3.1", "Level 3.1",
991  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level31 }, 0, 0, VE, .unit = "level" },
992  { "3.2", "Level 3.2",
993  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level32 }, 0, 0, VE, .unit = "level" },
994  { "3.3", "Level 3.3",
995  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level33 }, 0, 0, VE, .unit = "level" },
996  { "4", "Level 4",
997  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level4 }, 0, 0, VE, .unit = "level" },
998  { "4.1", "Level 4.1",
999  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level41 }, 0, 0, VE, .unit = "level" },
1000  { "4.2", "Level 4.2",
1001  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level42 }, 0, 0, VE, .unit = "level" },
1002  { "4.3", "Level 4.3",
1003  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level43 }, 0, 0, VE, .unit = "level" },
1004  { "5", "Level 5",
1005  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level5 }, 0, 0, VE, .unit = "level" },
1006  { "5.1", "Level 5.1",
1007  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level51 }, 0, 0, VE, .unit = "level" },
1008  { "5.2", "Level 5.2",
1009  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level52 }, 0, 0, VE, .unit = "level" },
1010  { "5.3", "Level 5.3",
1011  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level53 }, 0, 0, VE, .unit = "level" },
1012  { "6", "Level 6",
1013  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level6 }, 0, 0, VE, .unit = "level" },
1014  { "6.1", "Level 6.1",
1015  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level61 }, 0, 0, VE, .unit = "level" },
1016  { "6.2", "Level 6.2",
1017  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level62 }, 0, 0, VE, .unit = "level" },
1018  { "6.3", "Level 6.3",
1019  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level63 }, 0, 0, VE, .unit = "level" },
1020  { "7", "Level 7",
1021  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level7 }, 0, 0, VE, .unit = "level" },
1022  { "7.1", "Level 7.1",
1023  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level71 }, 0, 0, VE, .unit = "level" },
1024  { "7.2", "Level 7.2",
1025  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level72 }, 0, 0, VE, .unit = "level" },
1026  { "7.3", "Level 7.3",
1027  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level73 }, 0, 0, VE, .unit = "level" },
1028  { NULL, }
1029 };
1030 
1032 
1033 #endif // CONFIG_AV1_MEDIACODEC_ENCODER
MediaCodecEncContext
Definition: mediacodecenc.c:56
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:85
AVCodecContext::hwaccel_context
void * hwaccel_context
Legacy hardware accelerator context.
Definition: avcodec.h:1451
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:205
MediaCodecEncContext::pts_as_dts
int pts_as_dts
Definition: mediacodecenc.c:76
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:685
COLOR_FormatYUV420Planar
@ COLOR_FormatYUV420Planar
Definition: mediacodecenc.c:80
DECLARE_MEDIACODEC_ENCODER
#define DECLARE_MEDIACODEC_ENCODER(short_name, long_name, codec_id)
Definition: mediacodecenc.c:619
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:57
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:86
BITRATE_MODE_VBR
@ BITRATE_MODE_VBR
Definition: mediacodecenc.c:49
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:55
MediaCodecEncContext::fps
int fps
Definition: mediacodecenc.c:63
AV_PROFILE_HEVC_MAIN
#define AV_PROFILE_HEVC_MAIN
Definition: defs.h:158
out_size
int out_size
Definition: movenc.c:56
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:160
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
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:678
MediaCodecEncContext::window
FFANativeWindow * window
Definition: mediacodecenc.c:61
AVPacket::data
uint8_t * data
Definition: packet.h:524
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:45
ff_AMediaCodec_infoOutputFormatChanged
static int ff_AMediaCodec_infoOutputFormatChanged(FFAMediaCodec *codec, ssize_t idx)
Definition: mediacodec_wrapper.h:311
AVOption
AVOption.
Definition: opt.h:346
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
color_formats
static const struct @132 color_formats[]
MediaCodecEncContext::eof_sent
int eof_sent
Definition: mediacodecenc.c:69
COMMON_OPTION
#define COMMON_OPTION
Definition: mediacodecenc.c:591
mediacodec_encode
static int mediacodec_encode(AVCodecContext *avctx, AVPacket *pkt)
Definition: mediacodecenc.c:509
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:579
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
VE
#define VE
Definition: mediacodecenc.c:590
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:101
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:560
bsf.h
av1_options
static const AVOption av1_options[]
Definition: av1dec.c:1577
mediacodec_close
static av_cold int mediacodec_close(AVCodecContext *avctx)
Definition: mediacodecenc.c:556
MediaCodecEncContext::extradata
uint8_t * extradata
Definition: mediacodecenc.c:67
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:502
pix_fmt
enum AVPixelFormat pix_fmt
Definition: mediacodecenc.c:87
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:644
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:2494
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:355
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:60
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:148
mediacodec_send
static int mediacodec_send(AVCodecContext *avctx, const AVFrame *frame)
Definition: mediacodecenc.c:460
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:60
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:74
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:2932
BITRATE_MODE_CQ
@ BITRATE_MODE_CQ
Definition: mediacodecenc.c:47
AVCodecContext::global_quality
int global_quality
Global quality for codecs which cannot change it per frame.
Definition: avcodec.h:1239
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:26
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
COLOR_FormatSurface
@ COLOR_FormatSurface
Definition: mediacodecenc.c:82
OFFSET
#define OFFSET(x)
Definition: mediacodecenc.c:589
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:343
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
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition: avcodec.h:455
MediaCodecEncContext::use_ndk_codec
int use_ndk_codec
Definition: mediacodecenc.c:59
AV_PIX_FMT_MEDIACODEC
@ AV_PIX_FMT_MEDIACODEC
hardware decoding through MediaCodec
Definition: pixfmt.h:316
ff_AMediaFormatColorStandard_from_AVColorSpace
int ff_AMediaFormatColorStandard_from_AVColorSpace(enum AVColorSpace color_space)
Map AVColorSpace to MediaFormat color standard.
Definition: mediacodec_wrapper.c:2619
OUTPUT_DEQUEUE_TIMEOUT_US
#define OUTPUT_DEQUEUE_TIMEOUT_US
Definition: mediacodecenc.c:43
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:331
ff_AMediaCodec_getOutputFormat
static FFAMediaFormat * ff_AMediaCodec_getOutputFormat(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:286
MediaCodecEncContext::level
int level
Definition: mediacodecenc.c:75
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:2501
ff_AMediaFormatColorRange_from_AVColorRange
int ff_AMediaFormatColorRange_from_AVColorRange(enum AVColorRange color_range)
Map AVColorRange to MediaFormat color range.
Definition: mediacodec_wrapper.c:2602
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:695
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:280
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:2515
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:53
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:51
AV_PROFILE_HEVC_MAIN_10
#define AV_PROFILE_HEVC_MAIN_10
Definition: defs.h:159
index
int index
Definition: gxfenc.c:90
AVMediaCodecDeviceContext
MediaCodec details.
Definition: hwcontext_mediacodec.h:27
ff_AMediaFormat_toString
static char * ff_AMediaFormat_toString(FFAMediaFormat *format)
Definition: mediacodec_wrapper.h:97
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:544
AVCodecContext::gop_size
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
Definition: avcodec.h:1031
h264_options
static const AVOption h264_options[]
Definition: h264dec.c:1107
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:94
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:188
ff_AMediaFormatColorTransfer_from_AVColorTransfer
int ff_AMediaFormatColorTransfer_from_AVColorTransfer(enum AVColorTransferCharacteristic color_transfer)
Map AVColorTransferCharacteristic to MediaFormat color transfer.
Definition: mediacodec_wrapper.c:2647
AVCodecHWConfigInternal
Definition: hwconfig.h:25
MediaCodecEncContext::bsf
AVBSFContext * bsf
Definition: mediacodecenc.c:72
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:523
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:309
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:530
MediaCodecEncContext::name
const char * name
Definition: mediacodecenc.c:60
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
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:302
MediaCodecEncContext::width
int width
Definition: mediacodecenc.c:64
FF_MPEG4_PROFILE_OPTS
#define FF_MPEG4_PROFILE_OPTS
Definition: profiles.h:41
ff_AMediaCodec_getConfigureFlagEncode
static int ff_AMediaCodec_getConfigureFlagEncode(FFAMediaCodec *codec)
Definition: mediacodec_wrapper.h:331
MediaCodecEncContext::codec
FFAMediaCodec * codec
Definition: mediacodecenc.c:58
FFANativeWindow
Definition: mediacodec_surface.h:28
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
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:517
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:65
MediaCodecEncContext::extradata_size
int extradata_size
Definition: mediacodecenc.c:68
COLOR_FormatYUV420SemiPlanar
@ COLOR_FormatYUV420SemiPlanar
Definition: mediacodecenc.c:81
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:606
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:1497
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:71
INPUT_DEQUEUE_TIMEOUT_US
#define INPUT_DEQUEUE_TIMEOUT_US
Definition: mediacodecenc.c:42
AVCodecContext::height
int height
Definition: avcodec.h:618
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:657
av_jni_get_java_vm
void * av_jni_get_java_vm(void *log_ctx)
Definition: jni.c:75
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:72
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
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AVCodecContext::strict_std_compliance
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition: avcodec.h:1379
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:151
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:106
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:235
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
mem.h
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:795
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:205
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:501
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:618
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
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:576
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:244
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:433
mediacodec_init_bsf
static int mediacodec_init_bsf(AVCodecContext *avctx)
Definition: mediacodecenc.c:115
mediacodec.h