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  (avctx->codec_id == AV_CODEC_ID_H264 ||
205  avctx->codec_id == AV_CODEC_ID_HEVC)) {
206  s->width = FFALIGN(avctx->width, 16);
207  s->height = FFALIGN(avctx->height, 16);
208  // If avctx video size is aligned to 16 already, we don't need to do
209  // anything. If align is needed for HEVC, we should use the maximum CTU
210  // size.
211  if (avctx->codec_id == AV_CODEC_ID_HEVC &&
212  (s->width != avctx->width || s->height != avctx->height)) {
213  s->width = FFALIGN(avctx->width, 64);
214  s->height = FFALIGN(avctx->height, 64);
215  }
216  } else {
217  s->width = avctx->width;
218  s->height = avctx->height;
219  if (s->width % 16 || s->height % 16)
220  av_log(avctx, AV_LOG_WARNING,
221  "Video size %dx%d isn't align to 16, it may have device compatibility issue\n",
222  s->width, s->height);
223  }
224  ff_AMediaFormat_setInt32(format, "width", s->width);
225  ff_AMediaFormat_setInt32(format, "height", s->height);
226 
227  if (avctx->pix_fmt == AV_PIX_FMT_MEDIACODEC) {
228  AVMediaCodecContext *user_ctx = avctx->hwaccel_context;
229  if (avctx->hw_device_ctx) {
230  AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)(avctx->hw_device_ctx->data);
231  AVMediaCodecDeviceContext *dev_ctx;
232 
233  if (device_ctx->type != AV_HWDEVICE_TYPE_MEDIACODEC || !device_ctx->hwctx) {
234  ret = AVERROR(EINVAL);
235  goto bailout;
236  }
237  dev_ctx = device_ctx->hwctx;
238  s->window = ff_mediacodec_surface_ref(dev_ctx->surface, dev_ctx->native_window, avctx);
239  }
240 
241  if (!s->window && user_ctx && user_ctx->surface)
242  s->window = ff_mediacodec_surface_ref(user_ctx->surface, NULL, avctx);
243 
244  if (!s->window) {
245  ret = AVERROR(EINVAL);
246  av_log(avctx, AV_LOG_ERROR, "Missing hw_device_ctx or hwaccel_context for AV_PIX_FMT_MEDIACODEC\n");
247  goto bailout;
248  }
249  /* Although there is a method ANativeWindow_toSurface() introduced in
250  * API level 26, it's easier and safe to always require a Surface for
251  * Java MediaCodec.
252  */
253  if (!s->use_ndk_codec && !s->window->surface) {
254  ret = AVERROR(EINVAL);
255  av_log(avctx, AV_LOG_ERROR, "Missing jobject Surface for AV_PIX_FMT_MEDIACODEC. "
256  "Please note that Java MediaCodec doesn't work with ANativeWindow.\n");
257  goto bailout;
258  }
259  }
260 
261  for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
262  if (avctx->pix_fmt == color_formats[i].pix_fmt) {
263  ff_AMediaFormat_setInt32(format, "color-format",
265  break;
266  }
267  }
268 
271  ff_AMediaFormat_setInt32(format, "color-range", ret);
274  ff_AMediaFormat_setInt32(format, "color-standard", ret);
277  ff_AMediaFormat_setInt32(format, "color-transfer", ret);
278 
279  if (avctx->bit_rate)
280  ff_AMediaFormat_setInt32(format, "bitrate", avctx->bit_rate);
281  if (s->bitrate_mode >= 0) {
282  ff_AMediaFormat_setInt32(format, "bitrate-mode", s->bitrate_mode);
283  if (s->bitrate_mode == BITRATE_MODE_CQ && avctx->global_quality > 0)
284  ff_AMediaFormat_setInt32(format, "quality", avctx->global_quality);
285  }
286  // frame-rate and i-frame-interval are required to configure codec
287  if (avctx->framerate.num >= avctx->framerate.den && avctx->framerate.den > 0) {
288  s->fps = avctx->framerate.num / avctx->framerate.den;
289  } else {
290  s->fps = 30;
291  av_log(avctx, AV_LOG_INFO, "Use %d as the default MediaFormat frame-rate\n", s->fps);
292  }
293  gop = round(avctx->gop_size / s->fps);
294  if (gop == 0) {
295  gop = 1;
296  av_log(avctx, AV_LOG_INFO,
297  "Use %d as the default MediaFormat i-frame-interval, "
298  "please set gop_size properly (>= fps)\n", gop);
299  } else {
300  av_log(avctx, AV_LOG_DEBUG, "Set i-frame-interval to %d\n", gop);
301  }
302 
303  ff_AMediaFormat_setInt32(format, "frame-rate", s->fps);
304  ff_AMediaFormat_setInt32(format, "i-frame-interval", gop);
305 
307  if (ret > 0) {
308  av_log(avctx, AV_LOG_DEBUG, "set profile to 0x%x\n", ret);
309  ff_AMediaFormat_setInt32(format, "profile", ret);
310  }
311  if (s->level > 0) {
312  av_log(avctx, AV_LOG_DEBUG, "set level to 0x%x\n", s->level);
313  ff_AMediaFormat_setInt32(format, "level", s->level);
314  }
315  if (avctx->max_b_frames > 0) {
317  av_log(avctx, AV_LOG_ERROR,
318  "Enabling B frames will produce packets with no DTS. "
319  "Use -strict experimental to use it anyway.\n");
320  ret = AVERROR(EINVAL);
321  goto bailout;
322  }
323  ff_AMediaFormat_setInt32(format, "max-bframes", avctx->max_b_frames);
324  }
325  if (s->pts_as_dts == -1)
326  s->pts_as_dts = avctx->max_b_frames <= 0;
327 
329  ret = ff_AMediaCodec_configure(s->codec, format, s->window, NULL, ret);
330  if (ret) {
331  av_log(avctx, AV_LOG_ERROR, "MediaCodec configure failed, %s\n", av_err2str(ret));
332  if (avctx->pix_fmt == AV_PIX_FMT_YUV420P)
333  av_log(avctx, AV_LOG_ERROR, "Please try -pix_fmt nv12, some devices don't "
334  "support yuv420p as encoder input format.\n");
335  goto bailout;
336  }
337 
338  ret = ff_AMediaCodec_start(s->codec);
339  if (ret) {
340  av_log(avctx, AV_LOG_ERROR, "MediaCodec failed to start, %s\n", av_err2str(ret));
341  goto bailout;
342  }
343 
344  ret = mediacodec_init_bsf(avctx);
345  if (ret)
346  goto bailout;
347 
349  if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)
350  av_log(avctx, AV_LOG_WARNING,
351  "Mediacodec encoder doesn't support AV_CODEC_FLAG_GLOBAL_HEADER. "
352  "Use extract_extradata bsf when necessary.\n");
353 
354  s->frame = av_frame_alloc();
355  if (!s->frame)
356  ret = AVERROR(ENOMEM);
357 
358 bailout:
359  if (format)
361  return ret;
362 }
363 
365  AVPacket *pkt,
366  int *got_packet)
367 {
368  MediaCodecEncContext *s = avctx->priv_data;
369  FFAMediaCodec *codec = s->codec;
370  FFAMediaCodecBufferInfo out_info = {0};
371  uint8_t *out_buf;
372  size_t out_size = 0;
373  int ret;
374  int extradata_size = 0;
375  int64_t timeout_us = s->eof_sent ? OUTPUT_DEQUEUE_TIMEOUT_US : 0;
376  ssize_t index = ff_AMediaCodec_dequeueOutputBuffer(codec, &out_info, timeout_us);
377 
379  return AVERROR(EAGAIN);
380 
383  return AVERROR(EAGAIN);
384  }
385 
388  return AVERROR(EAGAIN);
389  }
390 
391  if (index < 0)
392  return AVERROR_EXTERNAL;
393 
394  if (out_info.flags & ff_AMediaCodec_getBufferFlagEndOfStream(codec))
395  return AVERROR_EOF;
396 
397  out_buf = ff_AMediaCodec_getOutputBuffer(codec, index, &out_size);
398  if (!out_buf) {
400  goto bailout;
401  }
402 
403  if (out_info.flags & ff_AMediaCodec_getBufferFlagCodecConfig(codec)) {
404  ret = av_reallocp(&s->extradata, out_info.size);
405  if (ret)
406  goto bailout;
407 
408  s->extradata_size = out_info.size;
409  memcpy(s->extradata, out_buf + out_info.offset, out_info.size);
411  // try immediately
412  return mediacodec_receive(avctx, pkt, got_packet);
413  }
414 
415  ret = ff_get_encode_buffer(avctx, pkt, out_info.size + s->extradata_size, 0);
416  if (ret < 0)
417  goto bailout;
418 
419  if (s->extradata_size) {
420  extradata_size = s->extradata_size;
421  s->extradata_size = 0;
422  memcpy(pkt->data, s->extradata, extradata_size);
423  }
424  memcpy(pkt->data + extradata_size, out_buf + out_info.offset, out_info.size);
426  if (s->pts_as_dts)
427  pkt->dts = pkt->pts;
428  if (out_info.flags & ff_AMediaCodec_getBufferFlagKeyFrame(codec))
430  ret = 0;
431  *got_packet = 1;
432 
433  av_log(avctx, AV_LOG_TRACE, "receive packet pts %" PRId64 " dts %" PRId64
434  " flags %d extradata %d\n",
435  pkt->pts, pkt->dts, pkt->flags, extradata_size);
436 
437 bailout:
439  return ret;
440 }
441 
442 static void copy_frame_to_buffer(AVCodecContext *avctx, const AVFrame *frame, uint8_t *dst, size_t size)
443 {
444  MediaCodecEncContext *s = avctx->priv_data;
445  uint8_t *dst_data[4] = {};
446  int dst_linesize[4] = {};
447 
448  if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) {
449  dst_data[0] = dst;
450  dst_data[1] = dst + s->width * s->height;
451  dst_data[2] = dst_data[1] + s->width * s->height / 4;
452 
453  dst_linesize[0] = s->width;
454  dst_linesize[1] = dst_linesize[2] = s->width / 2;
455  } else if (avctx->pix_fmt == AV_PIX_FMT_NV12) {
456  dst_data[0] = dst;
457  dst_data[1] = dst + s->width * s->height;
458 
459  dst_linesize[0] = s->width;
460  dst_linesize[1] = s->width;
461  } else {
462  av_assert0(0);
463  }
464 
465  av_image_copy2(dst_data, dst_linesize, frame->data, frame->linesize,
466  avctx->pix_fmt, avctx->width, avctx->height);
467 }
468 
469 static int mediacodec_send(AVCodecContext *avctx,
470  const AVFrame *frame) {
471  MediaCodecEncContext *s = avctx->priv_data;
472  FFAMediaCodec *codec = s->codec;
473  ssize_t index;
474  uint8_t *input_buf = NULL;
475  size_t input_size = 0;
476  int64_t pts = 0;
477  uint32_t flags = 0;
478  int64_t timeout_us;
479 
480  if (s->eof_sent)
481  return 0;
482 
483  if (s->window) {
484  if (!frame) {
485  s->eof_sent = 1;
487  }
488 
489  if (frame->data[3])
490  av_mediacodec_release_buffer((AVMediaCodecBuffer *)frame->data[3], 1);
491  return 0;
492  }
493 
494  timeout_us = INPUT_DEQUEUE_TIMEOUT_US;
495  index = ff_AMediaCodec_dequeueInputBuffer(codec, timeout_us);
497  return AVERROR(EAGAIN);
498 
499  if (index < 0) {
500  av_log(avctx, AV_LOG_ERROR, "dequeue input buffer failed, %zd", index);
501  return AVERROR_EXTERNAL;
502  }
503 
504  if (frame) {
505  input_buf = ff_AMediaCodec_getInputBuffer(codec, index, &input_size);
506  copy_frame_to_buffer(avctx, frame, input_buf, input_size);
507 
509  } else {
511  s->eof_sent = 1;
512  }
513 
514  ff_AMediaCodec_queueInputBuffer(codec, index, 0, input_size, pts, flags);
515  return 0;
516 }
517 
519 {
520  MediaCodecEncContext *s = avctx->priv_data;
521  int ret;
522  int got_packet = 0;
523 
524  // Return on three case:
525  // 1. Serious error
526  // 2. Got a packet success
527  // 3. No AVFrame is available yet (don't return if get_frame return EOF)
528  while (1) {
529  if (s->bsf) {
530  ret = av_bsf_receive_packet(s->bsf, pkt);
531  if (!ret)
532  return 0;
533  if (ret != AVERROR(EAGAIN))
534  return ret;
535  }
536 
537  ret = mediacodec_receive(avctx, pkt, &got_packet);
538  if (s->bsf) {
539  if (!ret || ret == AVERROR_EOF)
540  ret = av_bsf_send_packet(s->bsf, pkt);
541  } else {
542  if (!ret)
543  return 0;
544  }
545 
546  if (ret < 0 && ret != AVERROR(EAGAIN))
547  return ret;
548 
549  if (!s->frame->buf[0]) {
550  ret = ff_encode_get_frame(avctx, s->frame);
551  if (ret && ret != AVERROR_EOF)
552  return ret;
553  }
554 
555  ret = mediacodec_send(avctx, s->frame->buf[0] ? s->frame : NULL);
556  if (!ret)
557  av_frame_unref(s->frame);
558  else if (ret != AVERROR(EAGAIN))
559  return ret;
560  }
561 
562  return 0;
563 }
564 
566 {
567  MediaCodecEncContext *s = avctx->priv_data;
568  if (s->codec) {
569  ff_AMediaCodec_stop(s->codec);
570  ff_AMediaCodec_delete(s->codec);
571  s->codec = NULL;
572  }
573 
574  if (s->window) {
575  ff_mediacodec_surface_unref(s->window, avctx);
576  s->window = NULL;
577  }
578 
579  av_bsf_free(&s->bsf);
580  av_frame_free(&s->frame);
581 
582  return 0;
583 }
584 
586  &(const AVCodecHWConfigInternal) {
587  .public = {
591  .device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
592  },
593  .hwaccel = NULL,
594  },
595  NULL
596 };
597 
598 #define OFFSET(x) offsetof(MediaCodecEncContext, x)
599 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
600 #define COMMON_OPTION \
601  { "ndk_codec", "Use MediaCodec from NDK", \
602  OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, \
603  { "codec_name", "Select codec by name", \
604  OFFSET(name), AV_OPT_TYPE_STRING, {0}, 0, 0, VE }, \
605  { "bitrate_mode", "Bitrate control method", \
606  OFFSET(bitrate_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, .unit = "bitrate_mode" }, \
607  { "cq", "Constant quality mode", \
608  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CQ}, 0, 0, VE, .unit = "bitrate_mode" }, \
609  { "vbr", "Variable bitrate mode", \
610  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_VBR}, 0, 0, VE, .unit = "bitrate_mode" }, \
611  { "cbr", "Constant bitrate mode", \
612  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CBR}, 0, 0, VE, .unit = "bitrate_mode" }, \
613  { "cbr_fd", "Constant bitrate mode with frame drops", \
614  0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CBR_FD}, 0, 0, VE, .unit = "bitrate_mode" }, \
615  { "pts_as_dts", "Use PTS as DTS. It is enabled automatically if avctx max_b_frames <= 0, " \
616  "since most of Android devices don't output B frames by default.", \
617  OFFSET(pts_as_dts), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, \
618 
619 
620 #define MEDIACODEC_ENCODER_CLASS(name) \
621 static const AVClass name ## _mediacodec_class = { \
622  .class_name = #name "_mediacodec", \
623  .item_name = av_default_item_name, \
624  .option = name ## _options, \
625  .version = LIBAVUTIL_VERSION_INT, \
626 }; \
627 
628 #define DECLARE_MEDIACODEC_ENCODER(short_name, long_name, codec_id) \
629 MEDIACODEC_ENCODER_CLASS(short_name) \
630 const FFCodec ff_ ## short_name ## _mediacodec_encoder = { \
631  .p.name = #short_name "_mediacodec", \
632  CODEC_LONG_NAME(long_name " Android MediaCodec encoder"), \
633  .p.type = AVMEDIA_TYPE_VIDEO, \
634  .p.id = codec_id, \
635  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY \
636  | AV_CODEC_CAP_HARDWARE, \
637  .priv_data_size = sizeof(MediaCodecEncContext), \
638  .p.pix_fmts = avc_pix_fmts, \
639  .init = mediacodec_init, \
640  FF_CODEC_RECEIVE_PACKET_CB(mediacodec_encode), \
641  .close = mediacodec_close, \
642  .p.priv_class = &short_name ## _mediacodec_class, \
643  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \
644  .p.wrapper_name = "mediacodec", \
645  .hw_configs = mediacodec_hw_configs, \
646 }; \
647 
648 #if CONFIG_H264_MEDIACODEC_ENCODER
649 
650 enum MediaCodecAvcLevel {
651  AVCLevel1 = 0x01,
652  AVCLevel1b = 0x02,
653  AVCLevel11 = 0x04,
654  AVCLevel12 = 0x08,
655  AVCLevel13 = 0x10,
656  AVCLevel2 = 0x20,
657  AVCLevel21 = 0x40,
658  AVCLevel22 = 0x80,
659  AVCLevel3 = 0x100,
660  AVCLevel31 = 0x200,
661  AVCLevel32 = 0x400,
662  AVCLevel4 = 0x800,
663  AVCLevel41 = 0x1000,
664  AVCLevel42 = 0x2000,
665  AVCLevel5 = 0x4000,
666  AVCLevel51 = 0x8000,
667  AVCLevel52 = 0x10000,
668  AVCLevel6 = 0x20000,
669  AVCLevel61 = 0x40000,
670  AVCLevel62 = 0x80000,
671 };
672 
673 static const AVOption h264_options[] = {
675 
677  FF_AVCTX_PROFILE_OPTION("constrained_baseline", NULL, VIDEO, AV_PROFILE_H264_CONSTRAINED_BASELINE)
684 
685  { "level", "Specify level",
686  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
687  { "1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel1 }, 0, 0, VE, .unit = "level" },
688  { "1b", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel1b }, 0, 0, VE, .unit = "level" },
689  { "1.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel11 }, 0, 0, VE, .unit = "level" },
690  { "1.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel12 }, 0, 0, VE, .unit = "level" },
691  { "1.3", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel13 }, 0, 0, VE, .unit = "level" },
692  { "2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel2 }, 0, 0, VE, .unit = "level" },
693  { "2.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel21 }, 0, 0, VE, .unit = "level" },
694  { "2.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel22 }, 0, 0, VE, .unit = "level" },
695  { "3", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel3 }, 0, 0, VE, .unit = "level" },
696  { "3.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel31 }, 0, 0, VE, .unit = "level" },
697  { "3.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel32 }, 0, 0, VE, .unit = "level" },
698  { "4", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel4 }, 0, 0, VE, .unit = "level" },
699  { "4.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel41 }, 0, 0, VE, .unit = "level" },
700  { "4.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel42 }, 0, 0, VE, .unit = "level" },
701  { "5", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel5 }, 0, 0, VE, .unit = "level" },
702  { "5.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel51 }, 0, 0, VE, .unit = "level" },
703  { "5.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel52 }, 0, 0, VE, .unit = "level" },
704  { "6.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel6 }, 0, 0, VE, .unit = "level" },
705  { "6.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel61 }, 0, 0, VE, .unit = "level" },
706  { "6.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = AVCLevel62 }, 0, 0, VE, .unit = "level" },
707  { NULL, }
708 };
709 
711 
712 #endif // CONFIG_H264_MEDIACODEC_ENCODER
713 
714 #if CONFIG_HEVC_MEDIACODEC_ENCODER
715 
716 enum MediaCodecHevcLevel {
717  HEVCMainTierLevel1 = 0x1,
718  HEVCHighTierLevel1 = 0x2,
719  HEVCMainTierLevel2 = 0x4,
720  HEVCHighTierLevel2 = 0x8,
721  HEVCMainTierLevel21 = 0x10,
722  HEVCHighTierLevel21 = 0x20,
723  HEVCMainTierLevel3 = 0x40,
724  HEVCHighTierLevel3 = 0x80,
725  HEVCMainTierLevel31 = 0x100,
726  HEVCHighTierLevel31 = 0x200,
727  HEVCMainTierLevel4 = 0x400,
728  HEVCHighTierLevel4 = 0x800,
729  HEVCMainTierLevel41 = 0x1000,
730  HEVCHighTierLevel41 = 0x2000,
731  HEVCMainTierLevel5 = 0x4000,
732  HEVCHighTierLevel5 = 0x8000,
733  HEVCMainTierLevel51 = 0x10000,
734  HEVCHighTierLevel51 = 0x20000,
735  HEVCMainTierLevel52 = 0x40000,
736  HEVCHighTierLevel52 = 0x80000,
737  HEVCMainTierLevel6 = 0x100000,
738  HEVCHighTierLevel6 = 0x200000,
739  HEVCMainTierLevel61 = 0x400000,
740  HEVCHighTierLevel61 = 0x800000,
741  HEVCMainTierLevel62 = 0x1000000,
742  HEVCHighTierLevel62 = 0x2000000,
743 };
744 
745 static const AVOption hevc_options[] = {
747 
750 
751  { "level", "Specify tier and level",
752  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
753  { "m1", "Main tier level 1",
754  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel1 }, 0, 0, VE, .unit = "level" },
755  { "h1", "High tier level 1",
756  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel1 }, 0, 0, VE, .unit = "level" },
757  { "m2", "Main tier level 2",
758  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel2 }, 0, 0, VE, .unit = "level" },
759  { "h2", "High tier level 2",
760  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel2 }, 0, 0, VE, .unit = "level" },
761  { "m2.1", "Main tier level 2.1",
762  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel21 }, 0, 0, VE, .unit = "level" },
763  { "h2.1", "High tier level 2.1",
764  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel21 }, 0, 0, VE, .unit = "level" },
765  { "m3", "Main tier level 3",
766  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel3 }, 0, 0, VE, .unit = "level" },
767  { "h3", "High tier level 3",
768  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel3 }, 0, 0, VE, .unit = "level" },
769  { "m3.1", "Main tier level 3.1",
770  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel31 }, 0, 0, VE, .unit = "level" },
771  { "h3.1", "High tier level 3.1",
772  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel31 }, 0, 0, VE, .unit = "level" },
773  { "m4", "Main tier level 4",
774  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel4 }, 0, 0, VE, .unit = "level" },
775  { "h4", "High tier level 4",
776  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel4 }, 0, 0, VE, .unit = "level" },
777  { "m4.1", "Main tier level 4.1",
778  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel41 }, 0, 0, VE, .unit = "level" },
779  { "h4.1", "High tier level 4.1",
780  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel41 }, 0, 0, VE, .unit = "level" },
781  { "m5", "Main tier level 5",
782  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel5 }, 0, 0, VE, .unit = "level" },
783  { "h5", "High tier level 5",
784  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel5 }, 0, 0, VE, .unit = "level" },
785  { "m5.1", "Main tier level 5.1",
786  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel51 }, 0, 0, VE, .unit = "level" },
787  { "h5.1", "High tier level 5.1",
788  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel51 }, 0, 0, VE, .unit = "level" },
789  { "m5.2", "Main tier level 5.2",
790  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel52 }, 0, 0, VE, .unit = "level" },
791  { "h5.2", "High tier level 5.2",
792  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel52 }, 0, 0, VE, .unit = "level" },
793  { "m6", "Main tier level 6",
794  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel6 }, 0, 0, VE, .unit = "level" },
795  { "h6", "High tier level 6",
796  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel6 }, 0, 0, VE, .unit = "level" },
797  { "m6.1", "Main tier level 6.1",
798  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel61 }, 0, 0, VE, .unit = "level" },
799  { "h6.1", "High tier level 6.1",
800  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel61 }, 0, 0, VE, .unit = "level" },
801  { "m6.2", "Main tier level 6.2",
802  0, AV_OPT_TYPE_CONST, { .i64 = HEVCMainTierLevel62 }, 0, 0, VE, .unit = "level" },
803  { "h6.2", "High tier level 6.2",
804  0, AV_OPT_TYPE_CONST, { .i64 = HEVCHighTierLevel62 }, 0, 0, VE, .unit = "level" },
805  { NULL, }
806 };
807 
809 
810 #endif // CONFIG_HEVC_MEDIACODEC_ENCODER
811 
812 #if CONFIG_VP8_MEDIACODEC_ENCODER
813 
814 enum MediaCodecVP8Level {
815  VP8Level_Version0 = 0x01,
816  VP8Level_Version1 = 0x02,
817  VP8Level_Version2 = 0x04,
818  VP8Level_Version3 = 0x08,
819 };
820 
821 static const AVOption vp8_options[] = {
823  { "level", "Specify tier and level",
824  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
825  { "V0", "Level Version 0",
826  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version0 }, 0, 0, VE, .unit = "level" },
827  { "V1", "Level Version 1",
828  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version1 }, 0, 0, VE, .unit = "level" },
829  { "V2", "Level Version 2",
830  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version2 }, 0, 0, VE, .unit = "level" },
831  { "V3", "Level Version 3",
832  0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version3 }, 0, 0, VE, .unit = "level" },
833  { NULL, }
834 };
835 
837 
838 #endif // CONFIG_VP8_MEDIACODEC_ENCODER
839 
840 #if CONFIG_VP9_MEDIACODEC_ENCODER
841 
842 enum MediaCodecVP9Level {
843  VP9Level1 = 0x1,
844  VP9Level11 = 0x2,
845  VP9Level2 = 0x4,
846  VP9Level21 = 0x8,
847  VP9Level3 = 0x10,
848  VP9Level31 = 0x20,
849  VP9Level4 = 0x40,
850  VP9Level41 = 0x80,
851  VP9Level5 = 0x100,
852  VP9Level51 = 0x200,
853  VP9Level52 = 0x400,
854  VP9Level6 = 0x800,
855  VP9Level61 = 0x1000,
856  VP9Level62 = 0x2000,
857 };
858 
859 static const AVOption vp9_options[] = {
861 
862  FF_AVCTX_PROFILE_OPTION("profile0", NULL, VIDEO, AV_PROFILE_VP9_0)
863  FF_AVCTX_PROFILE_OPTION("profile1", NULL, VIDEO, AV_PROFILE_VP9_1)
864  FF_AVCTX_PROFILE_OPTION("profile2", NULL, VIDEO, AV_PROFILE_VP9_2)
865  FF_AVCTX_PROFILE_OPTION("profile3", NULL, VIDEO, AV_PROFILE_VP9_3)
866 
867  { "level", "Specify tier and level",
868  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
869  { "1", "Level 1",
870  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level1 }, 0, 0, VE, .unit = "level" },
871  { "1.1", "Level 1.1",
872  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level11 }, 0, 0, VE, .unit = "level" },
873  { "2", "Level 2",
874  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level2 }, 0, 0, VE, .unit = "level" },
875  { "2.1", "Level 2.1",
876  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level21 }, 0, 0, VE, .unit = "level" },
877  { "3", "Level 3",
878  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level3 }, 0, 0, VE, .unit = "level" },
879  { "3.1", "Level 3.1",
880  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level31 }, 0, 0, VE, .unit = "level" },
881  { "4", "Level 4",
882  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level4 }, 0, 0, VE, .unit = "level" },
883  { "4.1", "Level 4.1",
884  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level41 }, 0, 0, VE, .unit = "level" },
885  { "5", "Level 5",
886  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level5 }, 0, 0, VE, .unit = "level" },
887  { "5.1", "Level 5.1",
888  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level51 }, 0, 0, VE, .unit = "level" },
889  { "5.2", "Level 5.2",
890  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level52 }, 0, 0, VE, .unit = "level" },
891  { "6", "Level 6",
892  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level6 }, 0, 0, VE, .unit = "level" },
893  { "6.1", "Level 4.1",
894  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level61 }, 0, 0, VE, .unit = "level" },
895  { "6.2", "Level 6.2",
896  0, AV_OPT_TYPE_CONST, { .i64 = VP9Level62 }, 0, 0, VE, .unit = "level" },
897  { NULL, }
898 };
899 
901 
902 #endif // CONFIG_VP9_MEDIACODEC_ENCODER
903 
904 #if CONFIG_MPEG4_MEDIACODEC_ENCODER
905 
906 enum MediaCodecMpeg4Level {
907  MPEG4Level0 = 0x01,
908  MPEG4Level0b = 0x02,
909  MPEG4Level1 = 0x04,
910  MPEG4Level2 = 0x08,
911  MPEG4Level3 = 0x10,
912  MPEG4Level3b = 0x18,
913  MPEG4Level4 = 0x20,
914  MPEG4Level4a = 0x40,
915  MPEG4Level5 = 0x80,
916  MPEG4Level6 = 0x100,
917 };
918 
919 static const AVOption mpeg4_options[] = {
921 
923 
924  { "level", "Specify tier and level",
925  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
926  { "0", "Level 0",
927  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level0 }, 0, 0, VE, .unit = "level" },
928  { "0b", "Level 0b",
929  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level0b }, 0, 0, VE, .unit = "level" },
930  { "1", "Level 1",
931  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level1 }, 0, 0, VE, .unit = "level" },
932  { "2", "Level 2",
933  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level2 }, 0, 0, VE, .unit = "level" },
934  { "3", "Level 3",
935  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level3 }, 0, 0, VE, .unit = "level" },
936  { "3b", "Level 3b",
937  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level3b }, 0, 0, VE, .unit = "level" },
938  { "4", "Level 4",
939  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level4 }, 0, 0, VE, .unit = "level" },
940  { "4a", "Level 4a",
941  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level4a }, 0, 0, VE, .unit = "level" },
942  { "5", "Level 5",
943  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level5 }, 0, 0, VE, .unit = "level" },
944  { "6", "Level 6",
945  0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level6 }, 0, 0, VE, .unit = "level" },
946  { NULL, }
947 };
948 
950 
951 #endif // CONFIG_MPEG4_MEDIACODEC_ENCODER
952 
953 #if CONFIG_AV1_MEDIACODEC_ENCODER
954 
955 enum MediaCodecAV1Level {
956  AV1Level2 = 0x1,
957  AV1Level21 = 0x2,
958  AV1Level22 = 0x4,
959  AV1Level23 = 0x8,
960  AV1Level3 = 0x10,
961  AV1Level31 = 0x20,
962  AV1Level32 = 0x40,
963  AV1Level33 = 0x80,
964  AV1Level4 = 0x100,
965  AV1Level41 = 0x200,
966  AV1Level42 = 0x400,
967  AV1Level43 = 0x800,
968  AV1Level5 = 0x1000,
969  AV1Level51 = 0x2000,
970  AV1Level52 = 0x4000,
971  AV1Level53 = 0x8000,
972  AV1Level6 = 0x10000,
973  AV1Level61 = 0x20000,
974  AV1Level62 = 0x40000,
975  AV1Level63 = 0x80000,
976  AV1Level7 = 0x100000,
977  AV1Level71 = 0x200000,
978  AV1Level72 = 0x400000,
979  AV1Level73 = 0x800000,
980 };
981 
982 static const AVOption av1_options[] = {
984 
986 
987  { "level", "Specify tier and level",
988  OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, .unit = "level" },
989  { "2", "Level 2",
990  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level2 }, 0, 0, VE, .unit = "level" },
991  { "2.1", "Level 2.1",
992  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level21 }, 0, 0, VE, .unit = "level" },
993  { "2.2", "Level 2.2",
994  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level22 }, 0, 0, VE, .unit = "level" },
995  { "2.3", "Level 2.3",
996  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level23 }, 0, 0, VE, .unit = "level" },
997  { "3", "Level 3",
998  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level3 }, 0, 0, VE, .unit = "level" },
999  { "3.1", "Level 3.1",
1000  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level31 }, 0, 0, VE, .unit = "level" },
1001  { "3.2", "Level 3.2",
1002  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level32 }, 0, 0, VE, .unit = "level" },
1003  { "3.3", "Level 3.3",
1004  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level33 }, 0, 0, VE, .unit = "level" },
1005  { "4", "Level 4",
1006  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level4 }, 0, 0, VE, .unit = "level" },
1007  { "4.1", "Level 4.1",
1008  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level41 }, 0, 0, VE, .unit = "level" },
1009  { "4.2", "Level 4.2",
1010  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level42 }, 0, 0, VE, .unit = "level" },
1011  { "4.3", "Level 4.3",
1012  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level43 }, 0, 0, VE, .unit = "level" },
1013  { "5", "Level 5",
1014  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level5 }, 0, 0, VE, .unit = "level" },
1015  { "5.1", "Level 5.1",
1016  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level51 }, 0, 0, VE, .unit = "level" },
1017  { "5.2", "Level 5.2",
1018  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level52 }, 0, 0, VE, .unit = "level" },
1019  { "5.3", "Level 5.3",
1020  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level53 }, 0, 0, VE, .unit = "level" },
1021  { "6", "Level 6",
1022  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level6 }, 0, 0, VE, .unit = "level" },
1023  { "6.1", "Level 6.1",
1024  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level61 }, 0, 0, VE, .unit = "level" },
1025  { "6.2", "Level 6.2",
1026  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level62 }, 0, 0, VE, .unit = "level" },
1027  { "6.3", "Level 6.3",
1028  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level63 }, 0, 0, VE, .unit = "level" },
1029  { "7", "Level 7",
1030  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level7 }, 0, 0, VE, .unit = "level" },
1031  { "7.1", "Level 7.1",
1032  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level71 }, 0, 0, VE, .unit = "level" },
1033  { "7.2", "Level 7.2",
1034  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level72 }, 0, 0, VE, .unit = "level" },
1035  { "7.3", "Level 7.3",
1036  0, AV_OPT_TYPE_CONST, { .i64 = AV1Level73 }, 0, 0, VE, .unit = "level" },
1037  { NULL, }
1038 };
1039 
1041 
1042 #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: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: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:685
DECLARE_MEDIACODEC_ENCODER
#define DECLARE_MEDIACODEC_ENCODER(short_name, long_name, codec_id)
Definition: mediacodecenc.c:628
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
int64_t
long long int64_t
Definition: coverity.c:34
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:130
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
COLOR_FormatYUV420SemiPlanar
@ COLOR_FormatYUV420SemiPlanar
Definition: mediacodecenc.c:80
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:456
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: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: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
MediaCodecEncContext::eof_sent
int eof_sent
Definition: mediacodecenc.c:68
COMMON_OPTION
#define COMMON_OPTION
Definition: mediacodecenc.c:600
mediacodec_encode
static int mediacodec_encode(AVCodecContext *avctx, AVPacket *pkt)
Definition: mediacodecenc.c:518
COLOR_FormatYUV420Planar
@ COLOR_FormatYUV420Planar
Definition: mediacodecenc.c:79
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:365
VE
#define VE
Definition: mediacodecenc.c:599
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:560
bsf.h
av1_options
static const AVOption av1_options[]
Definition: av1dec.c:1587
mediacodec_close
static av_cold int mediacodec_close(AVCodecContext *avctx)
Definition: mediacodecenc.c:565
MediaCodecEncContext::extradata
uint8_t * extradata
Definition: mediacodecenc.c:66
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:502
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
COLOR_FormatSurface
@ COLOR_FormatSurface
Definition: mediacodecenc.c:81
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: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:364
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
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:118
mediacodec_send
static int mediacodec_send(AVCodecContext *avctx, const AVFrame *frame)
Definition: mediacodecenc.c:469
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:2938
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: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: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:598
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
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: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: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: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: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
color_formats
static const struct @123 color_formats[]
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: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:2647
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:309
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:528
MediaCodecEncContext::name
const char * name
Definition: mediacodecenc.c:59
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:576
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:70
INPUT_DEQUEUE_TIMEOUT_US
#define INPUT_DEQUEUE_TIMEOUT_US
Definition: mediacodecenc.c:41
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_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
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: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: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: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
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:204
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: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:482
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:389
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:585
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:442
mediacodec_init_bsf
static int mediacodec_init_bsf(AVCodecContext *avctx)
Definition: mediacodecenc.c:114
mediacodec.h