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.

965 lines
37KB

  1. /*
  2. * H.264 encoding using the x264 library
  3. * Copyright (C) 2005 Mans Rullgard <mans@mansr.com>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "libavutil/eval.h"
  22. #include "libavutil/internal.h"
  23. #include "libavutil/opt.h"
  24. #include "libavutil/mem.h"
  25. #include "libavutil/pixdesc.h"
  26. #include "libavutil/stereo3d.h"
  27. #include "avcodec.h"
  28. #include "internal.h"
  29. #if defined(_MSC_VER)
  30. #define X264_API_IMPORTS 1
  31. #endif
  32. #include <x264.h>
  33. #include <float.h>
  34. #include <math.h>
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37. #include <string.h>
  38. typedef struct X264Context {
  39. AVClass *class;
  40. x264_param_t params;
  41. x264_t *enc;
  42. x264_picture_t pic;
  43. uint8_t *sei;
  44. int sei_size;
  45. char *preset;
  46. char *tune;
  47. char *profile;
  48. char *level;
  49. int fastfirstpass;
  50. char *wpredp;
  51. char *x264opts;
  52. float crf;
  53. float crf_max;
  54. int cqp;
  55. int aq_mode;
  56. float aq_strength;
  57. char *psy_rd;
  58. int psy;
  59. int rc_lookahead;
  60. int weightp;
  61. int weightb;
  62. int ssim;
  63. int intra_refresh;
  64. int bluray_compat;
  65. int b_bias;
  66. int b_pyramid;
  67. int mixed_refs;
  68. int dct8x8;
  69. int fast_pskip;
  70. int aud;
  71. int mbtree;
  72. char *deblock;
  73. float cplxblur;
  74. char *partitions;
  75. int direct_pred;
  76. int slice_max_size;
  77. char *stats;
  78. int nal_hrd;
  79. int avcintra_class;
  80. char *x264_params;
  81. } X264Context;
  82. static void X264_log(void *p, int level, const char *fmt, va_list args)
  83. {
  84. static const int level_map[] = {
  85. [X264_LOG_ERROR] = AV_LOG_ERROR,
  86. [X264_LOG_WARNING] = AV_LOG_WARNING,
  87. [X264_LOG_INFO] = AV_LOG_INFO,
  88. [X264_LOG_DEBUG] = AV_LOG_DEBUG
  89. };
  90. if (level < 0 || level > X264_LOG_DEBUG)
  91. return;
  92. av_vlog(p, level_map[level], fmt, args);
  93. }
  94. static int encode_nals(AVCodecContext *ctx, AVPacket *pkt,
  95. const x264_nal_t *nals, int nnal)
  96. {
  97. X264Context *x4 = ctx->priv_data;
  98. uint8_t *p;
  99. int i, size = x4->sei_size, ret;
  100. if (!nnal)
  101. return 0;
  102. for (i = 0; i < nnal; i++)
  103. size += nals[i].i_payload;
  104. if ((ret = ff_alloc_packet2(ctx, pkt, size, 0)) < 0)
  105. return ret;
  106. p = pkt->data;
  107. /* Write the SEI as part of the first frame. */
  108. if (x4->sei_size > 0 && nnal > 0) {
  109. if (x4->sei_size > size) {
  110. av_log(ctx, AV_LOG_ERROR, "Error: nal buffer is too small\n");
  111. return -1;
  112. }
  113. memcpy(p, x4->sei, x4->sei_size);
  114. p += x4->sei_size;
  115. x4->sei_size = 0;
  116. av_freep(&x4->sei);
  117. }
  118. for (i = 0; i < nnal; i++){
  119. memcpy(p, nals[i].p_payload, nals[i].i_payload);
  120. p += nals[i].i_payload;
  121. }
  122. return 1;
  123. }
  124. static int avfmt2_num_planes(int avfmt)
  125. {
  126. switch (avfmt) {
  127. case AV_PIX_FMT_YUV420P:
  128. case AV_PIX_FMT_YUVJ420P:
  129. case AV_PIX_FMT_YUV420P9:
  130. case AV_PIX_FMT_YUV420P10:
  131. case AV_PIX_FMT_YUV444P:
  132. return 3;
  133. case AV_PIX_FMT_BGR0:
  134. case AV_PIX_FMT_BGR24:
  135. case AV_PIX_FMT_RGB24:
  136. return 1;
  137. default:
  138. return 3;
  139. }
  140. }
  141. static void reconfig_encoder(AVCodecContext *ctx, const AVFrame *frame)
  142. {
  143. X264Context *x4 = ctx->priv_data;
  144. AVFrameSideData *side_data;
  145. if (x4->avcintra_class < 0) {
  146. if (x4->params.b_interlaced && x4->params.b_tff != frame->top_field_first) {
  147. x4->params.b_tff = frame->top_field_first;
  148. x264_encoder_reconfig(x4->enc, &x4->params);
  149. }
  150. if (x4->params.vui.i_sar_height*ctx->sample_aspect_ratio.num != ctx->sample_aspect_ratio.den * x4->params.vui.i_sar_width) {
  151. x4->params.vui.i_sar_height = ctx->sample_aspect_ratio.den;
  152. x4->params.vui.i_sar_width = ctx->sample_aspect_ratio.num;
  153. x264_encoder_reconfig(x4->enc, &x4->params);
  154. }
  155. if (x4->params.rc.i_vbv_buffer_size != ctx->rc_buffer_size / 1000 ||
  156. x4->params.rc.i_vbv_max_bitrate != ctx->rc_max_rate / 1000) {
  157. x4->params.rc.i_vbv_buffer_size = ctx->rc_buffer_size / 1000;
  158. x4->params.rc.i_vbv_max_bitrate = ctx->rc_max_rate / 1000;
  159. x264_encoder_reconfig(x4->enc, &x4->params);
  160. }
  161. if (x4->params.rc.i_rc_method == X264_RC_ABR &&
  162. x4->params.rc.i_bitrate != ctx->bit_rate / 1000) {
  163. x4->params.rc.i_bitrate = ctx->bit_rate / 1000;
  164. x264_encoder_reconfig(x4->enc, &x4->params);
  165. }
  166. if (x4->crf >= 0 &&
  167. x4->params.rc.i_rc_method == X264_RC_CRF &&
  168. x4->params.rc.f_rf_constant != x4->crf) {
  169. x4->params.rc.f_rf_constant = x4->crf;
  170. x264_encoder_reconfig(x4->enc, &x4->params);
  171. }
  172. if (x4->params.rc.i_rc_method == X264_RC_CQP &&
  173. x4->cqp >= 0 &&
  174. x4->params.rc.i_qp_constant != x4->cqp) {
  175. x4->params.rc.i_qp_constant = x4->cqp;
  176. x264_encoder_reconfig(x4->enc, &x4->params);
  177. }
  178. if (x4->crf_max >= 0 &&
  179. x4->params.rc.f_rf_constant_max != x4->crf_max) {
  180. x4->params.rc.f_rf_constant_max = x4->crf_max;
  181. x264_encoder_reconfig(x4->enc, &x4->params);
  182. }
  183. }
  184. side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_STEREO3D);
  185. if (side_data) {
  186. AVStereo3D *stereo = (AVStereo3D *)side_data->data;
  187. int fpa_type;
  188. switch (stereo->type) {
  189. case AV_STEREO3D_CHECKERBOARD:
  190. fpa_type = 0;
  191. break;
  192. case AV_STEREO3D_COLUMNS:
  193. fpa_type = 1;
  194. break;
  195. case AV_STEREO3D_LINES:
  196. fpa_type = 2;
  197. break;
  198. case AV_STEREO3D_SIDEBYSIDE:
  199. fpa_type = 3;
  200. break;
  201. case AV_STEREO3D_TOPBOTTOM:
  202. fpa_type = 4;
  203. break;
  204. case AV_STEREO3D_FRAMESEQUENCE:
  205. fpa_type = 5;
  206. break;
  207. default:
  208. fpa_type = -1;
  209. break;
  210. }
  211. if (fpa_type != x4->params.i_frame_packing) {
  212. x4->params.i_frame_packing = fpa_type;
  213. x264_encoder_reconfig(x4->enc, &x4->params);
  214. }
  215. }
  216. }
  217. static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
  218. int *got_packet)
  219. {
  220. X264Context *x4 = ctx->priv_data;
  221. x264_nal_t *nal;
  222. int nnal, i, ret;
  223. x264_picture_t pic_out = {0};
  224. int pict_type;
  225. x264_picture_init( &x4->pic );
  226. x4->pic.img.i_csp = x4->params.i_csp;
  227. if (x264_bit_depth > 8)
  228. x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
  229. x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
  230. if (frame) {
  231. for (i = 0; i < x4->pic.img.i_plane; i++) {
  232. x4->pic.img.plane[i] = frame->data[i];
  233. x4->pic.img.i_stride[i] = frame->linesize[i];
  234. }
  235. x4->pic.i_pts = frame->pts;
  236. x4->pic.i_type =
  237. frame->pict_type == AV_PICTURE_TYPE_I ? X264_TYPE_KEYFRAME :
  238. frame->pict_type == AV_PICTURE_TYPE_P ? X264_TYPE_P :
  239. frame->pict_type == AV_PICTURE_TYPE_B ? X264_TYPE_B :
  240. X264_TYPE_AUTO;
  241. reconfig_encoder(ctx, frame);
  242. }
  243. do {
  244. if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
  245. return AVERROR_EXTERNAL;
  246. ret = encode_nals(ctx, pkt, nal, nnal);
  247. if (ret < 0)
  248. return ret;
  249. } while (!ret && !frame && x264_encoder_delayed_frames(x4->enc));
  250. pkt->pts = pic_out.i_pts;
  251. pkt->dts = pic_out.i_dts;
  252. switch (pic_out.i_type) {
  253. case X264_TYPE_IDR:
  254. case X264_TYPE_I:
  255. pict_type = AV_PICTURE_TYPE_I;
  256. break;
  257. case X264_TYPE_P:
  258. pict_type = AV_PICTURE_TYPE_P;
  259. break;
  260. case X264_TYPE_B:
  261. case X264_TYPE_BREF:
  262. pict_type = AV_PICTURE_TYPE_B;
  263. break;
  264. default:
  265. pict_type = AV_PICTURE_TYPE_NONE;
  266. }
  267. #if FF_API_CODED_FRAME
  268. FF_DISABLE_DEPRECATION_WARNINGS
  269. ctx->coded_frame->pict_type = pict_type;
  270. FF_ENABLE_DEPRECATION_WARNINGS
  271. #endif
  272. pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
  273. if (ret) {
  274. ff_side_data_set_encoder_stats(pkt, (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA, NULL, 0, pict_type);
  275. #if FF_API_CODED_FRAME
  276. FF_DISABLE_DEPRECATION_WARNINGS
  277. ctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
  278. FF_ENABLE_DEPRECATION_WARNINGS
  279. #endif
  280. }
  281. *got_packet = ret;
  282. return 0;
  283. }
  284. static av_cold int X264_close(AVCodecContext *avctx)
  285. {
  286. X264Context *x4 = avctx->priv_data;
  287. av_freep(&avctx->extradata);
  288. av_freep(&x4->sei);
  289. if (x4->enc) {
  290. x264_encoder_close(x4->enc);
  291. x4->enc = NULL;
  292. }
  293. return 0;
  294. }
  295. #define OPT_STR(opt, param) \
  296. do { \
  297. int ret; \
  298. if (param && (ret = x264_param_parse(&x4->params, opt, param)) < 0) { \
  299. if(ret == X264_PARAM_BAD_NAME) \
  300. av_log(avctx, AV_LOG_ERROR, \
  301. "bad option '%s': '%s'\n", opt, param); \
  302. else \
  303. av_log(avctx, AV_LOG_ERROR, \
  304. "bad value for '%s': '%s'\n", opt, param); \
  305. return -1; \
  306. } \
  307. } while (0)
  308. static int convert_pix_fmt(enum AVPixelFormat pix_fmt)
  309. {
  310. switch (pix_fmt) {
  311. case AV_PIX_FMT_YUV420P:
  312. case AV_PIX_FMT_YUVJ420P:
  313. case AV_PIX_FMT_YUV420P9:
  314. case AV_PIX_FMT_YUV420P10: return X264_CSP_I420;
  315. case AV_PIX_FMT_YUV422P:
  316. case AV_PIX_FMT_YUVJ422P:
  317. case AV_PIX_FMT_YUV422P10: return X264_CSP_I422;
  318. case AV_PIX_FMT_YUV444P:
  319. case AV_PIX_FMT_YUVJ444P:
  320. case AV_PIX_FMT_YUV444P9:
  321. case AV_PIX_FMT_YUV444P10: return X264_CSP_I444;
  322. #ifdef X264_CSP_BGR
  323. case AV_PIX_FMT_BGR0:
  324. return X264_CSP_BGRA;
  325. case AV_PIX_FMT_BGR24:
  326. return X264_CSP_BGR;
  327. case AV_PIX_FMT_RGB24:
  328. return X264_CSP_RGB;
  329. #endif
  330. case AV_PIX_FMT_NV12: return X264_CSP_NV12;
  331. case AV_PIX_FMT_NV16:
  332. case AV_PIX_FMT_NV20: return X264_CSP_NV16;
  333. };
  334. return 0;
  335. }
  336. #define PARSE_X264_OPT(name, var)\
  337. if (x4->var && x264_param_parse(&x4->params, name, x4->var) < 0) {\
  338. av_log(avctx, AV_LOG_ERROR, "Error parsing option '%s' with value '%s'.\n", name, x4->var);\
  339. return AVERROR(EINVAL);\
  340. }
  341. static av_cold int X264_init(AVCodecContext *avctx)
  342. {
  343. X264Context *x4 = avctx->priv_data;
  344. int sw,sh;
  345. if (avctx->global_quality > 0)
  346. av_log(avctx, AV_LOG_WARNING, "-qscale is ignored, -crf is recommended.\n");
  347. #if CONFIG_LIBX262_ENCODER
  348. if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
  349. x4->params.b_mpeg2 = 1;
  350. x264_param_default_mpeg2(&x4->params);
  351. } else
  352. #endif
  353. x264_param_default(&x4->params);
  354. x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER;
  355. if (x4->preset || x4->tune)
  356. if (x264_param_default_preset(&x4->params, x4->preset, x4->tune) < 0) {
  357. int i;
  358. av_log(avctx, AV_LOG_ERROR, "Error setting preset/tune %s/%s.\n", x4->preset, x4->tune);
  359. av_log(avctx, AV_LOG_INFO, "Possible presets:");
  360. for (i = 0; x264_preset_names[i]; i++)
  361. av_log(avctx, AV_LOG_INFO, " %s", x264_preset_names[i]);
  362. av_log(avctx, AV_LOG_INFO, "\n");
  363. av_log(avctx, AV_LOG_INFO, "Possible tunes:");
  364. for (i = 0; x264_tune_names[i]; i++)
  365. av_log(avctx, AV_LOG_INFO, " %s", x264_tune_names[i]);
  366. av_log(avctx, AV_LOG_INFO, "\n");
  367. return AVERROR(EINVAL);
  368. }
  369. if (avctx->level > 0)
  370. x4->params.i_level_idc = avctx->level;
  371. x4->params.pf_log = X264_log;
  372. x4->params.p_log_private = avctx;
  373. x4->params.i_log_level = X264_LOG_DEBUG;
  374. x4->params.i_csp = convert_pix_fmt(avctx->pix_fmt);
  375. OPT_STR("weightp", x4->wpredp);
  376. if (avctx->bit_rate) {
  377. x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
  378. x4->params.rc.i_rc_method = X264_RC_ABR;
  379. }
  380. x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
  381. x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
  382. x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1;
  383. if (avctx->flags & CODEC_FLAG_PASS2) {
  384. x4->params.rc.b_stat_read = 1;
  385. } else {
  386. if (x4->crf >= 0) {
  387. x4->params.rc.i_rc_method = X264_RC_CRF;
  388. x4->params.rc.f_rf_constant = x4->crf;
  389. } else if (x4->cqp >= 0) {
  390. x4->params.rc.i_rc_method = X264_RC_CQP;
  391. x4->params.rc.i_qp_constant = x4->cqp;
  392. }
  393. if (x4->crf_max >= 0)
  394. x4->params.rc.f_rf_constant_max = x4->crf_max;
  395. }
  396. if (avctx->rc_buffer_size && avctx->rc_initial_buffer_occupancy > 0 &&
  397. (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) {
  398. x4->params.rc.f_vbv_buffer_init =
  399. (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size;
  400. }
  401. OPT_STR("level", x4->level);
  402. if (avctx->i_quant_factor > 0)
  403. x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
  404. if (avctx->b_quant_factor > 0)
  405. x4->params.rc.f_pb_factor = avctx->b_quant_factor;
  406. if (avctx->chromaoffset)
  407. x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
  408. if (avctx->me_method == ME_EPZS)
  409. x4->params.analyse.i_me_method = X264_ME_DIA;
  410. else if (avctx->me_method == ME_HEX)
  411. x4->params.analyse.i_me_method = X264_ME_HEX;
  412. else if (avctx->me_method == ME_UMH)
  413. x4->params.analyse.i_me_method = X264_ME_UMH;
  414. else if (avctx->me_method == ME_FULL)
  415. x4->params.analyse.i_me_method = X264_ME_ESA;
  416. else if (avctx->me_method == ME_TESA)
  417. x4->params.analyse.i_me_method = X264_ME_TESA;
  418. if (avctx->gop_size >= 0)
  419. x4->params.i_keyint_max = avctx->gop_size;
  420. if (avctx->max_b_frames >= 0)
  421. x4->params.i_bframe = avctx->max_b_frames;
  422. if (avctx->scenechange_threshold >= 0)
  423. x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
  424. if (avctx->qmin >= 0)
  425. x4->params.rc.i_qp_min = avctx->qmin;
  426. if (avctx->qmax >= 0)
  427. x4->params.rc.i_qp_max = avctx->qmax;
  428. if (avctx->max_qdiff >= 0)
  429. x4->params.rc.i_qp_step = avctx->max_qdiff;
  430. if (avctx->qblur >= 0)
  431. x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */
  432. if (avctx->qcompress >= 0)
  433. x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */
  434. if (avctx->refs >= 0)
  435. x4->params.i_frame_reference = avctx->refs;
  436. else if (x4->level) {
  437. int i;
  438. int mbn = FF_CEIL_RSHIFT(avctx->width, 4) * FF_CEIL_RSHIFT(avctx->height, 4);
  439. int level_id = -1;
  440. char *tail;
  441. int scale = X264_BUILD < 129 ? 384 : 1;
  442. if (!strcmp(x4->level, "1b")) {
  443. level_id = 9;
  444. } else if (strlen(x4->level) <= 3){
  445. level_id = av_strtod(x4->level, &tail) * 10 + 0.5;
  446. if (*tail)
  447. level_id = -1;
  448. }
  449. if (level_id <= 0)
  450. av_log(avctx, AV_LOG_WARNING, "Failed to parse level\n");
  451. for (i = 0; i<x264_levels[i].level_idc; i++)
  452. if (x264_levels[i].level_idc == level_id)
  453. x4->params.i_frame_reference = av_clip(x264_levels[i].dpb / mbn / scale, 1, x4->params.i_frame_reference);
  454. }
  455. if (avctx->trellis >= 0)
  456. x4->params.analyse.i_trellis = avctx->trellis;
  457. if (avctx->me_range >= 0)
  458. x4->params.analyse.i_me_range = avctx->me_range;
  459. if (avctx->noise_reduction >= 0)
  460. x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
  461. if (avctx->me_subpel_quality >= 0)
  462. x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
  463. if (avctx->b_frame_strategy >= 0)
  464. x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
  465. if (avctx->keyint_min >= 0)
  466. x4->params.i_keyint_min = avctx->keyint_min;
  467. if (avctx->coder_type >= 0)
  468. x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
  469. if (avctx->me_cmp >= 0)
  470. x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
  471. if (x4->aq_mode >= 0)
  472. x4->params.rc.i_aq_mode = x4->aq_mode;
  473. if (x4->aq_strength >= 0)
  474. x4->params.rc.f_aq_strength = x4->aq_strength;
  475. PARSE_X264_OPT("psy-rd", psy_rd);
  476. PARSE_X264_OPT("deblock", deblock);
  477. PARSE_X264_OPT("partitions", partitions);
  478. PARSE_X264_OPT("stats", stats);
  479. if (x4->psy >= 0)
  480. x4->params.analyse.b_psy = x4->psy;
  481. if (x4->rc_lookahead >= 0)
  482. x4->params.rc.i_lookahead = x4->rc_lookahead;
  483. if (x4->weightp >= 0)
  484. x4->params.analyse.i_weighted_pred = x4->weightp;
  485. if (x4->weightb >= 0)
  486. x4->params.analyse.b_weighted_bipred = x4->weightb;
  487. if (x4->cplxblur >= 0)
  488. x4->params.rc.f_complexity_blur = x4->cplxblur;
  489. if (x4->ssim >= 0)
  490. x4->params.analyse.b_ssim = x4->ssim;
  491. if (x4->intra_refresh >= 0)
  492. x4->params.b_intra_refresh = x4->intra_refresh;
  493. if (x4->bluray_compat >= 0) {
  494. x4->params.b_bluray_compat = x4->bluray_compat;
  495. x4->params.b_vfr_input = 0;
  496. }
  497. if (x4->avcintra_class >= 0)
  498. #if X264_BUILD >= 142
  499. x4->params.i_avcintra_class = x4->avcintra_class;
  500. #else
  501. av_log(avctx, AV_LOG_ERROR,
  502. "x264 too old for AVC Intra, at least version 142 needed\n");
  503. #endif
  504. if (x4->b_bias != INT_MIN)
  505. x4->params.i_bframe_bias = x4->b_bias;
  506. if (x4->b_pyramid >= 0)
  507. x4->params.i_bframe_pyramid = x4->b_pyramid;
  508. if (x4->mixed_refs >= 0)
  509. x4->params.analyse.b_mixed_references = x4->mixed_refs;
  510. if (x4->dct8x8 >= 0)
  511. x4->params.analyse.b_transform_8x8 = x4->dct8x8;
  512. if (x4->fast_pskip >= 0)
  513. x4->params.analyse.b_fast_pskip = x4->fast_pskip;
  514. if (x4->aud >= 0)
  515. x4->params.b_aud = x4->aud;
  516. if (x4->mbtree >= 0)
  517. x4->params.rc.b_mb_tree = x4->mbtree;
  518. if (x4->direct_pred >= 0)
  519. x4->params.analyse.i_direct_mv_pred = x4->direct_pred;
  520. if (x4->slice_max_size >= 0)
  521. x4->params.i_slice_max_size = x4->slice_max_size;
  522. else {
  523. /*
  524. * Allow x264 to be instructed through AVCodecContext about the maximum
  525. * size of the RTP payload. For example, this enables the production of
  526. * payload suitable for the H.264 RTP packetization-mode 0 i.e. single
  527. * NAL unit per RTP packet.
  528. */
  529. if (avctx->rtp_payload_size)
  530. x4->params.i_slice_max_size = avctx->rtp_payload_size;
  531. }
  532. if (x4->fastfirstpass)
  533. x264_param_apply_fastfirstpass(&x4->params);
  534. /* Allow specifying the x264 profile through AVCodecContext. */
  535. if (!x4->profile)
  536. switch (avctx->profile) {
  537. case FF_PROFILE_H264_BASELINE:
  538. x4->profile = av_strdup("baseline");
  539. break;
  540. case FF_PROFILE_H264_HIGH:
  541. x4->profile = av_strdup("high");
  542. break;
  543. case FF_PROFILE_H264_HIGH_10:
  544. x4->profile = av_strdup("high10");
  545. break;
  546. case FF_PROFILE_H264_HIGH_422:
  547. x4->profile = av_strdup("high422");
  548. break;
  549. case FF_PROFILE_H264_HIGH_444:
  550. x4->profile = av_strdup("high444");
  551. break;
  552. case FF_PROFILE_H264_MAIN:
  553. x4->profile = av_strdup("main");
  554. break;
  555. default:
  556. break;
  557. }
  558. if (x4->nal_hrd >= 0)
  559. x4->params.i_nal_hrd = x4->nal_hrd;
  560. if (x4->profile)
  561. if (x264_param_apply_profile(&x4->params, x4->profile) < 0) {
  562. int i;
  563. av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile);
  564. av_log(avctx, AV_LOG_INFO, "Possible profiles:");
  565. for (i = 0; x264_profile_names[i]; i++)
  566. av_log(avctx, AV_LOG_INFO, " %s", x264_profile_names[i]);
  567. av_log(avctx, AV_LOG_INFO, "\n");
  568. return AVERROR(EINVAL);
  569. }
  570. x4->params.i_width = avctx->width;
  571. x4->params.i_height = avctx->height;
  572. av_reduce(&sw, &sh, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 4096);
  573. x4->params.vui.i_sar_width = sw;
  574. x4->params.vui.i_sar_height = sh;
  575. x4->params.i_timebase_den = avctx->time_base.den;
  576. x4->params.i_timebase_num = avctx->time_base.num;
  577. x4->params.i_fps_num = avctx->time_base.den;
  578. x4->params.i_fps_den = avctx->time_base.num * avctx->ticks_per_frame;
  579. x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR;
  580. x4->params.i_threads = avctx->thread_count;
  581. if (avctx->thread_type)
  582. x4->params.b_sliced_threads = avctx->thread_type == FF_THREAD_SLICE;
  583. x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
  584. x4->params.b_open_gop = !(avctx->flags & CODEC_FLAG_CLOSED_GOP);
  585. x4->params.i_slice_count = avctx->slices;
  586. x4->params.vui.b_fullrange = avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
  587. avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
  588. avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
  589. avctx->color_range == AVCOL_RANGE_JPEG;
  590. if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED)
  591. x4->params.vui.i_colmatrix = avctx->colorspace;
  592. if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED)
  593. x4->params.vui.i_colorprim = avctx->color_primaries;
  594. if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED)
  595. x4->params.vui.i_transfer = avctx->color_trc;
  596. if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
  597. x4->params.b_repeat_headers = 0;
  598. if(x4->x264opts){
  599. const char *p= x4->x264opts;
  600. while(p){
  601. char param[256]={0}, val[256]={0};
  602. if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){
  603. OPT_STR(param, "1");
  604. }else
  605. OPT_STR(param, val);
  606. p= strchr(p, ':');
  607. p+=!!p;
  608. }
  609. }
  610. if (x4->x264_params) {
  611. AVDictionary *dict = NULL;
  612. AVDictionaryEntry *en = NULL;
  613. if (!av_dict_parse_string(&dict, x4->x264_params, "=", ":", 0)) {
  614. while ((en = av_dict_get(dict, "", en, AV_DICT_IGNORE_SUFFIX))) {
  615. if (x264_param_parse(&x4->params, en->key, en->value) < 0)
  616. av_log(avctx, AV_LOG_WARNING,
  617. "Error parsing option '%s = %s'.\n",
  618. en->key, en->value);
  619. }
  620. av_dict_free(&dict);
  621. }
  622. }
  623. // update AVCodecContext with x264 parameters
  624. avctx->has_b_frames = x4->params.i_bframe ?
  625. x4->params.i_bframe_pyramid ? 2 : 1 : 0;
  626. if (avctx->max_b_frames < 0)
  627. avctx->max_b_frames = 0;
  628. avctx->bit_rate = x4->params.rc.i_bitrate*1000;
  629. x4->enc = x264_encoder_open(&x4->params);
  630. if (!x4->enc)
  631. return AVERROR_EXTERNAL;
  632. if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
  633. x264_nal_t *nal;
  634. uint8_t *p;
  635. int nnal, s, i;
  636. s = x264_encoder_headers(x4->enc, &nal, &nnal);
  637. avctx->extradata = p = av_malloc(s);
  638. if (!p)
  639. return AVERROR(ENOMEM);
  640. for (i = 0; i < nnal; i++) {
  641. /* Don't put the SEI in extradata. */
  642. if (nal[i].i_type == NAL_SEI) {
  643. av_log(avctx, AV_LOG_INFO, "%s\n", nal[i].p_payload+25);
  644. x4->sei_size = nal[i].i_payload;
  645. x4->sei = av_malloc(x4->sei_size);
  646. if (!x4->sei)
  647. return AVERROR(ENOMEM);
  648. memcpy(x4->sei, nal[i].p_payload, nal[i].i_payload);
  649. continue;
  650. }
  651. memcpy(p, nal[i].p_payload, nal[i].i_payload);
  652. p += nal[i].i_payload;
  653. }
  654. avctx->extradata_size = p - avctx->extradata;
  655. }
  656. return 0;
  657. }
  658. static const enum AVPixelFormat pix_fmts_8bit[] = {
  659. AV_PIX_FMT_YUV420P,
  660. AV_PIX_FMT_YUVJ420P,
  661. AV_PIX_FMT_YUV422P,
  662. AV_PIX_FMT_YUVJ422P,
  663. AV_PIX_FMT_YUV444P,
  664. AV_PIX_FMT_YUVJ444P,
  665. AV_PIX_FMT_NV12,
  666. AV_PIX_FMT_NV16,
  667. AV_PIX_FMT_NONE
  668. };
  669. static const enum AVPixelFormat pix_fmts_9bit[] = {
  670. AV_PIX_FMT_YUV420P9,
  671. AV_PIX_FMT_YUV444P9,
  672. AV_PIX_FMT_NONE
  673. };
  674. static const enum AVPixelFormat pix_fmts_10bit[] = {
  675. AV_PIX_FMT_YUV420P10,
  676. AV_PIX_FMT_YUV422P10,
  677. AV_PIX_FMT_YUV444P10,
  678. AV_PIX_FMT_NV20,
  679. AV_PIX_FMT_NONE
  680. };
  681. static const enum AVPixelFormat pix_fmts_8bit_rgb[] = {
  682. #ifdef X264_CSP_BGR
  683. AV_PIX_FMT_BGR0,
  684. AV_PIX_FMT_BGR24,
  685. AV_PIX_FMT_RGB24,
  686. #endif
  687. AV_PIX_FMT_NONE
  688. };
  689. static av_cold void X264_init_static(AVCodec *codec)
  690. {
  691. if (x264_bit_depth == 8)
  692. codec->pix_fmts = pix_fmts_8bit;
  693. else if (x264_bit_depth == 9)
  694. codec->pix_fmts = pix_fmts_9bit;
  695. else if (x264_bit_depth == 10)
  696. codec->pix_fmts = pix_fmts_10bit;
  697. }
  698. #define OFFSET(x) offsetof(X264Context, x)
  699. #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
  700. static const AVOption options[] = {
  701. { "preset", "Set the encoding preset (cf. x264 --fullhelp)", OFFSET(preset), AV_OPT_TYPE_STRING, { .str = "medium" }, 0, 0, VE},
  702. { "tune", "Tune the encoding params (cf. x264 --fullhelp)", OFFSET(tune), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
  703. { "profile", "Set profile restrictions (cf. x264 --fullhelp) ", OFFSET(profile), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
  704. { "fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE},
  705. {"level", "Specify level (as defined by Annex A)", OFFSET(level), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
  706. {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
  707. {"wpredp", "Weighted prediction for P-frames", OFFSET(wpredp), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
  708. {"x264opts", "x264 options", OFFSET(x264opts), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
  709. { "crf", "Select the quality for constant quality mode", OFFSET(crf), AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, VE },
  710. { "crf_max", "In CRF mode, prevents VBV from lowering quality beyond this point.",OFFSET(crf_max), AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, VE },
  711. { "qp", "Constant quantization parameter rate control method",OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE },
  712. { "aq-mode", "AQ method", OFFSET(aq_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE, "aq_mode"},
  713. { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_AQ_NONE}, INT_MIN, INT_MAX, VE, "aq_mode" },
  714. { "variance", "Variance AQ (complexity mask)", 0, AV_OPT_TYPE_CONST, {.i64 = X264_AQ_VARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" },
  715. { "autovariance", "Auto-variance AQ", 0, AV_OPT_TYPE_CONST, {.i64 = X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" },
  716. #if X264_BUILD >= 144
  717. { "autovariance-biased", "Auto-variance AQ with bias to dark scenes", 0, AV_OPT_TYPE_CONST, {.i64 = X264_AQ_AUTOVARIANCE_BIASED}, INT_MIN, INT_MAX, VE, "aq_mode" },
  718. #endif
  719. { "aq-strength", "AQ strength. Reduces blocking and blurring in flat and textured areas.", OFFSET(aq_strength), AV_OPT_TYPE_FLOAT, {.dbl = -1}, -1, FLT_MAX, VE},
  720. { "psy", "Use psychovisual optimizations.", OFFSET(psy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
  721. { "psy-rd", "Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.", OFFSET(psy_rd), AV_OPT_TYPE_STRING, {0 }, 0, 0, VE},
  722. { "rc-lookahead", "Number of frames to look ahead for frametype and ratecontrol", OFFSET(rc_lookahead), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE },
  723. { "weightb", "Weighted prediction for B-frames.", OFFSET(weightb), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
  724. { "weightp", "Weighted prediction analysis method.", OFFSET(weightp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE, "weightp" },
  725. { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_WEIGHTP_NONE}, INT_MIN, INT_MAX, VE, "weightp" },
  726. { "simple", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_WEIGHTP_SIMPLE}, INT_MIN, INT_MAX, VE, "weightp" },
  727. { "smart", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_WEIGHTP_SMART}, INT_MIN, INT_MAX, VE, "weightp" },
  728. { "ssim", "Calculate and print SSIM stats.", OFFSET(ssim), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
  729. { "intra-refresh", "Use Periodic Intra Refresh instead of IDR frames.",OFFSET(intra_refresh),AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
  730. { "bluray-compat", "Bluray compatibility workarounds.", OFFSET(bluray_compat) ,AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE },
  731. { "b-bias", "Influences how often B-frames are used", OFFSET(b_bias), AV_OPT_TYPE_INT, { .i64 = INT_MIN}, INT_MIN, INT_MAX, VE },
  732. { "b-pyramid", "Keep some B-frames as references.", OFFSET(b_pyramid), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE, "b_pyramid" },
  733. { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_B_PYRAMID_NONE}, INT_MIN, INT_MAX, VE, "b_pyramid" },
  734. { "strict", "Strictly hierarchical pyramid", 0, AV_OPT_TYPE_CONST, {.i64 = X264_B_PYRAMID_STRICT}, INT_MIN, INT_MAX, VE, "b_pyramid" },
  735. { "normal", "Non-strict (not Blu-ray compatible)", 0, AV_OPT_TYPE_CONST, {.i64 = X264_B_PYRAMID_NORMAL}, INT_MIN, INT_MAX, VE, "b_pyramid" },
  736. { "mixed-refs", "One reference per partition, as opposed to one reference per macroblock", OFFSET(mixed_refs), AV_OPT_TYPE_INT, { .i64 = -1}, -1, 1, VE },
  737. { "8x8dct", "High profile 8x8 transform.", OFFSET(dct8x8), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE},
  738. { "fast-pskip", NULL, OFFSET(fast_pskip), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE},
  739. { "aud", "Use access unit delimiters.", OFFSET(aud), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE},
  740. { "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE},
  741. { "deblock", "Loop filter parameters, in <alpha:beta> form.", OFFSET(deblock), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
  742. { "cplxblur", "Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, VE},
  743. { "partitions", "A comma-separated list of partitions to consider. "
  744. "Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all", OFFSET(partitions), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
  745. { "direct-pred", "Direct MV prediction mode", OFFSET(direct_pred), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE, "direct-pred" },
  746. { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_DIRECT_PRED_NONE }, 0, 0, VE, "direct-pred" },
  747. { "spatial", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_DIRECT_PRED_SPATIAL }, 0, 0, VE, "direct-pred" },
  748. { "temporal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_DIRECT_PRED_TEMPORAL }, 0, 0, VE, "direct-pred" },
  749. { "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_DIRECT_PRED_AUTO }, 0, 0, VE, "direct-pred" },
  750. { "slice-max-size","Limit the size of each slice in bytes", OFFSET(slice_max_size),AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE },
  751. { "stats", "Filename for 2 pass stats", OFFSET(stats), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
  752. { "nal-hrd", "Signal HRD information (requires vbv-bufsize; "
  753. "cbr not allowed in .mp4)", OFFSET(nal_hrd), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE, "nal-hrd" },
  754. { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_NONE}, INT_MIN, INT_MAX, VE, "nal-hrd" },
  755. { "vbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_VBR}, INT_MIN, INT_MAX, VE, "nal-hrd" },
  756. { "cbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_CBR}, INT_MIN, INT_MAX, VE, "nal-hrd" },
  757. { "avcintra-class","AVC-Intra class 50/100/200", OFFSET(avcintra_class),AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 200 , VE},
  758. { "x264-params", "Override the x264 configuration using a :-separated list of key=value parameters", OFFSET(x264_params), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
  759. { NULL },
  760. };
  761. static const AVCodecDefault x264_defaults[] = {
  762. { "b", "0" },
  763. { "bf", "-1" },
  764. { "flags2", "0" },
  765. { "g", "-1" },
  766. { "i_qfactor", "-1" },
  767. { "b_qfactor", "-1" },
  768. { "qmin", "-1" },
  769. { "qmax", "-1" },
  770. { "qdiff", "-1" },
  771. { "qblur", "-1" },
  772. { "qcomp", "-1" },
  773. // { "rc_lookahead", "-1" },
  774. { "refs", "-1" },
  775. { "sc_threshold", "-1" },
  776. { "trellis", "-1" },
  777. { "nr", "-1" },
  778. { "me_range", "-1" },
  779. { "me_method", "-1" },
  780. { "subq", "-1" },
  781. { "b_strategy", "-1" },
  782. { "keyint_min", "-1" },
  783. { "coder", "-1" },
  784. { "cmp", "-1" },
  785. { "threads", AV_STRINGIFY(X264_THREADS_AUTO) },
  786. { "thread_type", "0" },
  787. { "flags", "+cgop" },
  788. { "rc_init_occupancy","-1" },
  789. { NULL },
  790. };
  791. #if CONFIG_LIBX264_ENCODER
  792. static const AVClass x264_class = {
  793. .class_name = "libx264",
  794. .item_name = av_default_item_name,
  795. .option = options,
  796. .version = LIBAVUTIL_VERSION_INT,
  797. };
  798. static const AVClass rgbclass = {
  799. .class_name = "libx264rgb",
  800. .item_name = av_default_item_name,
  801. .option = options,
  802. .version = LIBAVUTIL_VERSION_INT,
  803. };
  804. AVCodec ff_libx264_encoder = {
  805. .name = "libx264",
  806. .long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
  807. .type = AVMEDIA_TYPE_VIDEO,
  808. .id = AV_CODEC_ID_H264,
  809. .priv_data_size = sizeof(X264Context),
  810. .init = X264_init,
  811. .encode2 = X264_frame,
  812. .close = X264_close,
  813. .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS,
  814. .priv_class = &x264_class,
  815. .defaults = x264_defaults,
  816. .init_static_data = X264_init_static,
  817. .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
  818. FF_CODEC_CAP_INIT_CLEANUP,
  819. };
  820. AVCodec ff_libx264rgb_encoder = {
  821. .name = "libx264rgb",
  822. .long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB"),
  823. .type = AVMEDIA_TYPE_VIDEO,
  824. .id = AV_CODEC_ID_H264,
  825. .priv_data_size = sizeof(X264Context),
  826. .init = X264_init,
  827. .encode2 = X264_frame,
  828. .close = X264_close,
  829. .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS,
  830. .priv_class = &rgbclass,
  831. .defaults = x264_defaults,
  832. .pix_fmts = pix_fmts_8bit_rgb,
  833. };
  834. #endif
  835. #if CONFIG_LIBX262_ENCODER
  836. static const AVClass X262_class = {
  837. .class_name = "libx262",
  838. .item_name = av_default_item_name,
  839. .option = options,
  840. .version = LIBAVUTIL_VERSION_INT,
  841. };
  842. AVCodec ff_libx262_encoder = {
  843. .name = "libx262",
  844. .long_name = NULL_IF_CONFIG_SMALL("libx262 MPEG2VIDEO"),
  845. .type = AVMEDIA_TYPE_VIDEO,
  846. .id = AV_CODEC_ID_MPEG2VIDEO,
  847. .priv_data_size = sizeof(X264Context),
  848. .init = X264_init,
  849. .encode2 = X264_frame,
  850. .close = X264_close,
  851. .capabilities = CODEC_CAP_DELAY | CODEC_CAP_AUTO_THREADS,
  852. .priv_class = &X262_class,
  853. .defaults = x264_defaults,
  854. .pix_fmts = pix_fmts_8bit,
  855. .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
  856. FF_CODEC_CAP_INIT_CLEANUP,
  857. };
  858. #endif