You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

515 lines
19KB

  1. /*
  2. * Copyright (c) 2010, Google, Inc.
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * VP8 encoder support via libvpx
  23. */
  24. #define VPX_DISABLE_CTRL_TYPECHECKS 1
  25. #define VPX_CODEC_DISABLE_COMPAT 1
  26. #include <vpx/vpx_encoder.h>
  27. #include <vpx/vp8cx.h>
  28. #include "avcodec.h"
  29. #include "libavutil/base64.h"
  30. /**
  31. * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
  32. * One encoded frame returned from the library.
  33. */
  34. struct FrameListData {
  35. void *buf; /**< compressed data buffer */
  36. size_t sz; /**< length of compressed data */
  37. int64_t pts; /**< time stamp to show frame
  38. (in timebase units) */
  39. unsigned long duration; /**< duration to show frame
  40. (in timebase units) */
  41. uint32_t flags; /**< flags for this frame */
  42. struct FrameListData *next;
  43. };
  44. typedef struct VP8EncoderContext {
  45. struct vpx_codec_ctx encoder;
  46. struct vpx_image rawimg;
  47. struct vpx_fixed_buf twopass_stats;
  48. unsigned long deadline; //i.e., RT/GOOD/BEST
  49. struct FrameListData *coded_frame_list;
  50. } VP8Context;
  51. /** String mappings for enum vp8e_enc_control_id */
  52. static const char *ctlidstr[] = {
  53. [VP8E_UPD_ENTROPY] = "VP8E_UPD_ENTROPY",
  54. [VP8E_UPD_REFERENCE] = "VP8E_UPD_REFERENCE",
  55. [VP8E_USE_REFERENCE] = "VP8E_USE_REFERENCE",
  56. [VP8E_SET_ROI_MAP] = "VP8E_SET_ROI_MAP",
  57. [VP8E_SET_ACTIVEMAP] = "VP8E_SET_ACTIVEMAP",
  58. [VP8E_SET_SCALEMODE] = "VP8E_SET_SCALEMODE",
  59. [VP8E_SET_CPUUSED] = "VP8E_SET_CPUUSED",
  60. [VP8E_SET_ENABLEAUTOALTREF] = "VP8E_SET_ENABLEAUTOALTREF",
  61. [VP8E_SET_NOISE_SENSITIVITY] = "VP8E_SET_NOISE_SENSITIVITY",
  62. [VP8E_SET_SHARPNESS] = "VP8E_SET_SHARPNESS",
  63. [VP8E_SET_STATIC_THRESHOLD] = "VP8E_SET_STATIC_THRESHOLD",
  64. [VP8E_SET_TOKEN_PARTITIONS] = "VP8E_SET_TOKEN_PARTITIONS",
  65. [VP8E_GET_LAST_QUANTIZER] = "VP8E_GET_LAST_QUANTIZER",
  66. [VP8E_SET_ARNR_MAXFRAMES] = "VP8E_SET_ARNR_MAXFRAMES",
  67. [VP8E_SET_ARNR_STRENGTH] = "VP8E_SET_ARNR_STRENGTH",
  68. [VP8E_SET_ARNR_TYPE] = "VP8E_SET_ARNR_TYPE",
  69. [VP8E_SET_CQ_LEVEL] = "VP8E_SET_CQ_LEVEL",
  70. };
  71. static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
  72. {
  73. VP8Context *ctx = avctx->priv_data;
  74. const char *error = vpx_codec_error(&ctx->encoder);
  75. const char *detail = vpx_codec_error_detail(&ctx->encoder);
  76. av_log(avctx, AV_LOG_ERROR, "%s: %s\n", desc, error);
  77. if (detail)
  78. av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", detail);
  79. }
  80. static av_cold void dump_enc_cfg(AVCodecContext *avctx,
  81. const struct vpx_codec_enc_cfg *cfg)
  82. {
  83. int width = -30;
  84. int level = AV_LOG_DEBUG;
  85. av_log(avctx, level, "vpx_codec_enc_cfg\n");
  86. av_log(avctx, level, "generic settings\n"
  87. " %*s%u\n %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
  88. " %*s{%u/%u}\n %*s%u\n %*s%d\n %*s%u\n",
  89. width, "g_usage:", cfg->g_usage,
  90. width, "g_threads:", cfg->g_threads,
  91. width, "g_profile:", cfg->g_profile,
  92. width, "g_w:", cfg->g_w,
  93. width, "g_h:", cfg->g_h,
  94. width, "g_timebase:", cfg->g_timebase.num, cfg->g_timebase.den,
  95. width, "g_error_resilient:", cfg->g_error_resilient,
  96. width, "g_pass:", cfg->g_pass,
  97. width, "g_lag_in_frames:", cfg->g_lag_in_frames);
  98. av_log(avctx, level, "rate control settings\n"
  99. " %*s%u\n %*s%u\n %*s%u\n %*s%u\n"
  100. " %*s%d\n %*s%p(%zu)\n %*s%u\n",
  101. width, "rc_dropframe_thresh:", cfg->rc_dropframe_thresh,
  102. width, "rc_resize_allowed:", cfg->rc_resize_allowed,
  103. width, "rc_resize_up_thresh:", cfg->rc_resize_up_thresh,
  104. width, "rc_resize_down_thresh:", cfg->rc_resize_down_thresh,
  105. width, "rc_end_usage:", cfg->rc_end_usage,
  106. width, "rc_twopass_stats_in:", cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz,
  107. width, "rc_target_bitrate:", cfg->rc_target_bitrate);
  108. av_log(avctx, level, "quantizer settings\n"
  109. " %*s%u\n %*s%u\n",
  110. width, "rc_min_quantizer:", cfg->rc_min_quantizer,
  111. width, "rc_max_quantizer:", cfg->rc_max_quantizer);
  112. av_log(avctx, level, "bitrate tolerance\n"
  113. " %*s%u\n %*s%u\n",
  114. width, "rc_undershoot_pct:", cfg->rc_undershoot_pct,
  115. width, "rc_overshoot_pct:", cfg->rc_overshoot_pct);
  116. av_log(avctx, level, "decoder buffer model\n"
  117. " %*s%u\n %*s%u\n %*s%u\n",
  118. width, "rc_buf_sz:", cfg->rc_buf_sz,
  119. width, "rc_buf_initial_sz:", cfg->rc_buf_initial_sz,
  120. width, "rc_buf_optimal_sz:", cfg->rc_buf_optimal_sz);
  121. av_log(avctx, level, "2 pass rate control settings\n"
  122. " %*s%u\n %*s%u\n %*s%u\n",
  123. width, "rc_2pass_vbr_bias_pct:", cfg->rc_2pass_vbr_bias_pct,
  124. width, "rc_2pass_vbr_minsection_pct:", cfg->rc_2pass_vbr_minsection_pct,
  125. width, "rc_2pass_vbr_maxsection_pct:", cfg->rc_2pass_vbr_maxsection_pct);
  126. av_log(avctx, level, "keyframing settings\n"
  127. " %*s%d\n %*s%u\n %*s%u\n",
  128. width, "kf_mode:", cfg->kf_mode,
  129. width, "kf_min_dist:", cfg->kf_min_dist,
  130. width, "kf_max_dist:", cfg->kf_max_dist);
  131. av_log(avctx, level, "\n");
  132. }
  133. static void coded_frame_add(void *list, struct FrameListData *cx_frame)
  134. {
  135. struct FrameListData **p = list;
  136. while (*p != NULL)
  137. p = &(*p)->next;
  138. *p = cx_frame;
  139. cx_frame->next = NULL;
  140. }
  141. static av_cold void free_coded_frame(struct FrameListData *cx_frame)
  142. {
  143. av_freep(&cx_frame->buf);
  144. av_freep(&cx_frame);
  145. }
  146. static av_cold void free_frame_list(struct FrameListData *list)
  147. {
  148. struct FrameListData *p = list;
  149. while (p) {
  150. list = list->next;
  151. free_coded_frame(p);
  152. p = list;
  153. }
  154. }
  155. static av_cold int codecctl_int(AVCodecContext *avctx,
  156. enum vp8e_enc_control_id id, int val)
  157. {
  158. VP8Context *ctx = avctx->priv_data;
  159. char buf[80];
  160. int width = -30;
  161. int res;
  162. snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
  163. av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, val);
  164. res = vpx_codec_control(&ctx->encoder, id, val);
  165. if (res != VPX_CODEC_OK) {
  166. snprintf(buf, sizeof(buf), "Failed to set %s codec control",
  167. ctlidstr[id]);
  168. log_encoder_error(avctx, buf);
  169. }
  170. return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL);
  171. }
  172. static av_cold int vp8_free(AVCodecContext *avctx)
  173. {
  174. VP8Context *ctx = avctx->priv_data;
  175. vpx_codec_destroy(&ctx->encoder);
  176. av_freep(&ctx->twopass_stats.buf);
  177. av_freep(&avctx->coded_frame);
  178. av_freep(&avctx->stats_out);
  179. free_frame_list(ctx->coded_frame_list);
  180. return 0;
  181. }
  182. static av_cold int vp8_init(AVCodecContext *avctx)
  183. {
  184. VP8Context *ctx = avctx->priv_data;
  185. const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo;
  186. int cpuused = 3;
  187. struct vpx_codec_enc_cfg enccfg;
  188. int res;
  189. av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
  190. av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
  191. if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) {
  192. av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
  193. vpx_codec_err_to_string(res));
  194. return AVERROR(EINVAL);
  195. }
  196. dump_enc_cfg(avctx, &enccfg);
  197. enccfg.g_w = avctx->width;
  198. enccfg.g_h = avctx->height;
  199. enccfg.g_timebase.num = avctx->time_base.num;
  200. enccfg.g_timebase.den = avctx->time_base.den;
  201. enccfg.g_threads = avctx->thread_count;
  202. if (avctx->flags & CODEC_FLAG_PASS1)
  203. enccfg.g_pass = VPX_RC_FIRST_PASS;
  204. else if (avctx->flags & CODEC_FLAG_PASS2)
  205. enccfg.g_pass = VPX_RC_LAST_PASS;
  206. else
  207. enccfg.g_pass = VPX_RC_ONE_PASS;
  208. if (avctx->rc_min_rate == avctx->rc_max_rate &&
  209. avctx->rc_min_rate == avctx->bit_rate)
  210. enccfg.rc_end_usage = VPX_CBR;
  211. else if (avctx->crf)
  212. enccfg.rc_end_usage = VPX_CQ;
  213. enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
  214. AV_ROUND_NEAR_INF);
  215. enccfg.rc_min_quantizer = avctx->qmin;
  216. enccfg.rc_max_quantizer = avctx->qmax;
  217. enccfg.rc_dropframe_thresh = avctx->frame_skip_threshold;
  218. //0-100 (0 => CBR, 100 => VBR)
  219. enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);
  220. enccfg.rc_2pass_vbr_minsection_pct =
  221. avctx->rc_min_rate * 100LL / avctx->bit_rate;
  222. if (avctx->rc_max_rate)
  223. enccfg.rc_2pass_vbr_maxsection_pct =
  224. avctx->rc_max_rate * 100LL / avctx->bit_rate;
  225. if (avctx->rc_buffer_size)
  226. enccfg.rc_buf_sz =
  227. avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
  228. if (avctx->rc_initial_buffer_occupancy)
  229. enccfg.rc_buf_initial_sz =
  230. avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
  231. enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
  232. //_enc_init() will balk if kf_min_dist differs from max w/VPX_KF_AUTO
  233. if (avctx->keyint_min == avctx->gop_size)
  234. enccfg.kf_min_dist = avctx->keyint_min;
  235. enccfg.kf_max_dist = avctx->gop_size;
  236. if (enccfg.g_pass == VPX_RC_FIRST_PASS)
  237. enccfg.g_lag_in_frames = 0;
  238. else if (enccfg.g_pass == VPX_RC_LAST_PASS) {
  239. int decode_size;
  240. if (!avctx->stats_in) {
  241. av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n");
  242. return AVERROR_INVALIDDATA;
  243. }
  244. ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;
  245. ctx->twopass_stats.buf = av_malloc(ctx->twopass_stats.sz);
  246. if (!ctx->twopass_stats.buf) {
  247. av_log(avctx, AV_LOG_ERROR,
  248. "Stat buffer alloc (%zu bytes) failed\n",
  249. ctx->twopass_stats.sz);
  250. return AVERROR(ENOMEM);
  251. }
  252. decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
  253. ctx->twopass_stats.sz);
  254. if (decode_size < 0) {
  255. av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n");
  256. return AVERROR_INVALIDDATA;
  257. }
  258. ctx->twopass_stats.sz = decode_size;
  259. enccfg.rc_twopass_stats_in = ctx->twopass_stats;
  260. }
  261. ctx->deadline = VPX_DL_GOOD_QUALITY;
  262. /* 0-3: For non-zero values the encoder increasingly optimizes for reduced
  263. complexity playback on low powered devices at the expense of encode
  264. quality. */
  265. if (avctx->profile != FF_PROFILE_UNKNOWN)
  266. enccfg.g_profile = avctx->profile;
  267. dump_enc_cfg(avctx, &enccfg);
  268. /* Construct Encoder Context */
  269. res = vpx_codec_enc_init(&ctx->encoder, iface, &enccfg, 0);
  270. if (res != VPX_CODEC_OK) {
  271. log_encoder_error(avctx, "Failed to initialize encoder");
  272. return AVERROR(EINVAL);
  273. }
  274. //codec control failures are currently treated only as warnings
  275. av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
  276. codecctl_int(avctx, VP8E_SET_CPUUSED, cpuused);
  277. codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
  278. codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
  279. codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx->mb_threshold);
  280. codecctl_int(avctx, VP8E_SET_CQ_LEVEL, (int)avctx->crf);
  281. //provide dummy value to initialize wrapper, values will be updated each _encode()
  282. vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
  283. (unsigned char*)1);
  284. avctx->coded_frame = avcodec_alloc_frame();
  285. if (!avctx->coded_frame) {
  286. av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n");
  287. vp8_free(avctx);
  288. return AVERROR(ENOMEM);
  289. }
  290. return 0;
  291. }
  292. static inline void cx_pktcpy(struct FrameListData *dst,
  293. const struct vpx_codec_cx_pkt *src)
  294. {
  295. dst->pts = src->data.frame.pts;
  296. dst->duration = src->data.frame.duration;
  297. dst->flags = src->data.frame.flags;
  298. dst->sz = src->data.frame.sz;
  299. dst->buf = src->data.frame.buf;
  300. }
  301. /**
  302. * Store coded frame information in format suitable for return from encode().
  303. *
  304. * Write buffer information from @a cx_frame to @a buf & @a buf_size.
  305. * Timing/frame details to @a coded_frame.
  306. * @return Frame size written to @a buf on success
  307. * @return AVERROR(EINVAL) on error
  308. */
  309. static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
  310. uint8_t *buf, int buf_size, AVFrame *coded_frame)
  311. {
  312. if ((int) cx_frame->sz <= buf_size) {
  313. buf_size = cx_frame->sz;
  314. memcpy(buf, cx_frame->buf, buf_size);
  315. coded_frame->pts = cx_frame->pts;
  316. coded_frame->key_frame = !!(cx_frame->flags & VPX_FRAME_IS_KEY);
  317. if (coded_frame->key_frame)
  318. coded_frame->pict_type = AV_PICTURE_TYPE_I;
  319. else
  320. coded_frame->pict_type = AV_PICTURE_TYPE_P;
  321. } else {
  322. av_log(avctx, AV_LOG_ERROR,
  323. "Compressed frame larger than storage provided! (%zu/%d)\n",
  324. cx_frame->sz, buf_size);
  325. return AVERROR(EINVAL);
  326. }
  327. return buf_size;
  328. }
  329. /**
  330. * Queue multiple output frames from the encoder, returning the front-most.
  331. * In cases where vpx_codec_get_cx_data() returns more than 1 frame append
  332. * the frame queue. Return the head frame if available.
  333. * @return Stored frame size
  334. * @return AVERROR(EINVAL) on output size error
  335. * @return AVERROR(ENOMEM) on coded frame queue data allocation error
  336. */
  337. static int queue_frames(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  338. AVFrame *coded_frame)
  339. {
  340. VP8Context *ctx = avctx->priv_data;
  341. const struct vpx_codec_cx_pkt *pkt;
  342. const void *iter = NULL;
  343. int size = 0;
  344. if (ctx->coded_frame_list) {
  345. struct FrameListData *cx_frame = ctx->coded_frame_list;
  346. /* return the leading frame if we've already begun queueing */
  347. size = storeframe(avctx, cx_frame, buf, buf_size, coded_frame);
  348. if (size < 0)
  349. return AVERROR(EINVAL);
  350. ctx->coded_frame_list = cx_frame->next;
  351. free_coded_frame(cx_frame);
  352. }
  353. /* consume all available output from the encoder before returning. buffers
  354. are only good through the next vpx_codec call */
  355. while ((pkt = vpx_codec_get_cx_data(&ctx->encoder, &iter))) {
  356. switch (pkt->kind) {
  357. case VPX_CODEC_CX_FRAME_PKT:
  358. if (!size) {
  359. struct FrameListData cx_frame;
  360. /* avoid storing the frame when the list is empty and we haven't yet
  361. provided a frame for output */
  362. assert(!ctx->coded_frame_list);
  363. cx_pktcpy(&cx_frame, pkt);
  364. size = storeframe(avctx, &cx_frame, buf, buf_size, coded_frame);
  365. if (size < 0)
  366. return AVERROR(EINVAL);
  367. } else {
  368. struct FrameListData *cx_frame =
  369. av_malloc(sizeof(struct FrameListData));
  370. if (!cx_frame) {
  371. av_log(avctx, AV_LOG_ERROR,
  372. "Frame queue element alloc failed\n");
  373. return AVERROR(ENOMEM);
  374. }
  375. cx_pktcpy(cx_frame, pkt);
  376. cx_frame->buf = av_malloc(cx_frame->sz);
  377. if (!cx_frame->buf) {
  378. av_log(avctx, AV_LOG_ERROR,
  379. "Data buffer alloc (%zu bytes) failed\n",
  380. cx_frame->sz);
  381. return AVERROR(ENOMEM);
  382. }
  383. memcpy(cx_frame->buf, pkt->data.frame.buf, pkt->data.frame.sz);
  384. coded_frame_add(&ctx->coded_frame_list, cx_frame);
  385. }
  386. break;
  387. case VPX_CODEC_STATS_PKT: {
  388. struct vpx_fixed_buf *stats = &ctx->twopass_stats;
  389. stats->buf = av_realloc(stats->buf,
  390. stats->sz + pkt->data.twopass_stats.sz);
  391. if (!stats->buf) {
  392. av_log(avctx, AV_LOG_ERROR, "Stat buffer realloc failed\n");
  393. return AVERROR(ENOMEM);
  394. }
  395. memcpy((uint8_t*)stats->buf + stats->sz,
  396. pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz);
  397. stats->sz += pkt->data.twopass_stats.sz;
  398. break;
  399. }
  400. case VPX_CODEC_PSNR_PKT: //FIXME add support for CODEC_FLAG_PSNR
  401. case VPX_CODEC_CUSTOM_PKT:
  402. //ignore unsupported/unrecognized packet types
  403. break;
  404. }
  405. }
  406. return size;
  407. }
  408. static int vp8_encode(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  409. void *data)
  410. {
  411. VP8Context *ctx = avctx->priv_data;
  412. AVFrame *frame = data;
  413. struct vpx_image *rawimg = NULL;
  414. int64_t timestamp = 0;
  415. int res, coded_size;
  416. if (frame) {
  417. rawimg = &ctx->rawimg;
  418. rawimg->planes[VPX_PLANE_Y] = frame->data[0];
  419. rawimg->planes[VPX_PLANE_U] = frame->data[1];
  420. rawimg->planes[VPX_PLANE_V] = frame->data[2];
  421. rawimg->stride[VPX_PLANE_Y] = frame->linesize[0];
  422. rawimg->stride[VPX_PLANE_U] = frame->linesize[1];
  423. rawimg->stride[VPX_PLANE_V] = frame->linesize[2];
  424. timestamp = frame->pts;
  425. }
  426. res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp,
  427. avctx->ticks_per_frame, 0, ctx->deadline);
  428. if (res != VPX_CODEC_OK) {
  429. log_encoder_error(avctx, "Error encoding frame");
  430. return AVERROR_INVALIDDATA;
  431. }
  432. coded_size = queue_frames(avctx, buf, buf_size, avctx->coded_frame);
  433. if (!frame && avctx->flags & CODEC_FLAG_PASS1) {
  434. unsigned int b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz);
  435. avctx->stats_out = av_malloc(b64_size);
  436. if (!avctx->stats_out) {
  437. av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%d bytes) failed\n",
  438. b64_size);
  439. return AVERROR(ENOMEM);
  440. }
  441. av_base64_encode(avctx->stats_out, b64_size, ctx->twopass_stats.buf,
  442. ctx->twopass_stats.sz);
  443. }
  444. return coded_size;
  445. }
  446. AVCodec ff_libvpx_encoder = {
  447. "libvpx",
  448. AVMEDIA_TYPE_VIDEO,
  449. CODEC_ID_VP8,
  450. sizeof(VP8Context),
  451. vp8_init,
  452. vp8_encode,
  453. vp8_free,
  454. NULL,
  455. CODEC_CAP_DELAY,
  456. .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
  457. .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"),
  458. };