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