obs-ffmpeg-audio-encoders.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. /******************************************************************************
  2. Copyright (C) 2023 by Lain Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include <util/base.h>
  15. #include <util/deque.h>
  16. #include <util/darray.h>
  17. #include <util/dstr.h>
  18. #include <obs-module.h>
  19. #include <libavutil/channel_layout.h>
  20. #include <libavformat/avformat.h>
  21. #include "obs-ffmpeg-formats.h"
  22. #include "obs-ffmpeg-compat.h"
  23. #define do_log(level, format, ...) \
  24. blog(level, "[FFmpeg %s encoder: '%s'] " format, enc->type, \
  25. obs_encoder_get_name(enc->encoder), ##__VA_ARGS__)
  26. #define warn(format, ...) do_log(LOG_WARNING, format, ##__VA_ARGS__)
  27. #define info(format, ...) do_log(LOG_INFO, format, ##__VA_ARGS__)
  28. #define debug(format, ...) do_log(LOG_DEBUG, format, ##__VA_ARGS__)
  29. struct enc_encoder {
  30. obs_encoder_t *encoder;
  31. const char *type;
  32. const AVCodec *codec;
  33. AVCodecContext *context;
  34. uint8_t *samples[MAX_AV_PLANES];
  35. AVFrame *aframe;
  36. int64_t total_samples;
  37. DARRAY(uint8_t) packet_buffer;
  38. size_t audio_planes;
  39. size_t audio_size;
  40. int frame_size; /* pretty much always 1024 for AAC */
  41. int frame_size_bytes;
  42. };
  43. #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 24, 100)
  44. static inline uint64_t convert_speaker_layout(enum speaker_layout layout)
  45. {
  46. switch (layout) {
  47. case SPEAKERS_UNKNOWN:
  48. return 0;
  49. case SPEAKERS_MONO:
  50. return AV_CH_LAYOUT_MONO;
  51. case SPEAKERS_STEREO:
  52. return AV_CH_LAYOUT_STEREO;
  53. case SPEAKERS_2POINT1:
  54. return AV_CH_LAYOUT_SURROUND;
  55. case SPEAKERS_4POINT0:
  56. return AV_CH_LAYOUT_4POINT0;
  57. case SPEAKERS_4POINT1:
  58. return AV_CH_LAYOUT_4POINT1;
  59. case SPEAKERS_5POINT1:
  60. return AV_CH_LAYOUT_5POINT1_BACK;
  61. case SPEAKERS_7POINT1:
  62. return AV_CH_LAYOUT_7POINT1;
  63. }
  64. /* shouldn't get here */
  65. return 0;
  66. }
  67. #endif
  68. static const char *aac_getname(void *unused)
  69. {
  70. UNUSED_PARAMETER(unused);
  71. return obs_module_text("FFmpegAAC");
  72. }
  73. static const char *opus_getname(void *unused)
  74. {
  75. UNUSED_PARAMETER(unused);
  76. return obs_module_text("FFmpegOpus");
  77. }
  78. static const char *pcm_getname(void *unused)
  79. {
  80. UNUSED_PARAMETER(unused);
  81. return obs_module_text("FFmpegPCM16Bit");
  82. }
  83. static const char *pcm24_getname(void *unused)
  84. {
  85. UNUSED_PARAMETER(unused);
  86. return obs_module_text("FFmpegPCM24Bit");
  87. }
  88. static const char *pcm32_getname(void *unused)
  89. {
  90. UNUSED_PARAMETER(unused);
  91. return obs_module_text("FFmpegPCM32BitFloat");
  92. }
  93. static const char *alac_getname(void *unused)
  94. {
  95. UNUSED_PARAMETER(unused);
  96. return obs_module_text("FFmpegALAC");
  97. }
  98. static const char *flac_getname(void *unused)
  99. {
  100. UNUSED_PARAMETER(unused);
  101. return obs_module_text("FFmpegFLAC");
  102. }
  103. static void enc_destroy(void *data)
  104. {
  105. struct enc_encoder *enc = data;
  106. if (enc->samples[0])
  107. av_freep(&enc->samples[0]);
  108. if (enc->context)
  109. avcodec_free_context(&enc->context);
  110. if (enc->aframe)
  111. av_frame_free(&enc->aframe);
  112. da_free(enc->packet_buffer);
  113. bfree(enc);
  114. }
  115. static bool initialize_codec(struct enc_encoder *enc)
  116. {
  117. int ret;
  118. int channels;
  119. enc->aframe = av_frame_alloc();
  120. if (!enc->aframe) {
  121. warn("Failed to allocate audio frame");
  122. return false;
  123. }
  124. ret = avcodec_open2(enc->context, enc->codec, NULL);
  125. if (ret < 0) {
  126. struct dstr error_message = {0};
  127. dstr_printf(&error_message, "Failed to open AAC codec: %s",
  128. av_err2str(ret));
  129. obs_encoder_set_last_error(enc->encoder, error_message.array);
  130. dstr_free(&error_message);
  131. warn("Failed to open AAC codec: %s", av_err2str(ret));
  132. return false;
  133. }
  134. enc->aframe->format = enc->context->sample_fmt;
  135. #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(57, 24, 100)
  136. enc->aframe->channels = enc->context->channels;
  137. channels = enc->context->channels;
  138. #else
  139. channels = enc->context->ch_layout.nb_channels;
  140. #endif
  141. #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 24, 100)
  142. enc->aframe->channel_layout = enc->context->channel_layout;
  143. #else
  144. enc->aframe->ch_layout = enc->context->ch_layout;
  145. #endif
  146. enc->aframe->sample_rate = enc->context->sample_rate;
  147. enc->frame_size = enc->context->frame_size;
  148. if (!enc->frame_size)
  149. enc->frame_size = 1024;
  150. enc->frame_size_bytes = enc->frame_size * (int)enc->audio_size;
  151. ret = av_samples_alloc(enc->samples, NULL, channels, enc->frame_size,
  152. enc->context->sample_fmt, 0);
  153. if (ret < 0) {
  154. warn("Failed to create audio buffer: %s", av_err2str(ret));
  155. return false;
  156. }
  157. return true;
  158. }
  159. static void init_sizes(struct enc_encoder *enc, audio_t *audio)
  160. {
  161. const struct audio_output_info *aoi;
  162. enum audio_format format;
  163. aoi = audio_output_get_info(audio);
  164. format = convert_ffmpeg_sample_format(enc->context->sample_fmt);
  165. enc->audio_planes = get_audio_planes(format, aoi->speakers);
  166. enc->audio_size = get_audio_size(format, aoi->speakers, 1);
  167. }
  168. #ifndef MIN
  169. #define MIN(x, y) ((x) < (y) ? (x) : (y))
  170. #endif
  171. static void *enc_create(obs_data_t *settings, obs_encoder_t *encoder,
  172. const char *type, const char *alt,
  173. enum AVSampleFormat sample_format)
  174. {
  175. struct enc_encoder *enc;
  176. int bitrate = (int)obs_data_get_int(settings, "bitrate");
  177. audio_t *audio = obs_encoder_audio(encoder);
  178. enc = bzalloc(sizeof(struct enc_encoder));
  179. enc->encoder = encoder;
  180. enc->codec = avcodec_find_encoder_by_name(type);
  181. enc->type = type;
  182. if (!enc->codec && alt) {
  183. enc->codec = avcodec_find_encoder_by_name(alt);
  184. enc->type = alt;
  185. }
  186. blog(LOG_INFO, "---------------------------------");
  187. if (!enc->codec) {
  188. warn("Couldn't find encoder");
  189. goto fail;
  190. }
  191. const AVCodecDescriptor *codec_desc =
  192. avcodec_descriptor_get(enc->codec->id);
  193. if (!codec_desc) {
  194. warn("Failed to get codec descriptor");
  195. goto fail;
  196. }
  197. if (!bitrate && !(codec_desc->props & AV_CODEC_PROP_LOSSLESS)) {
  198. warn("Invalid bitrate specified");
  199. goto fail;
  200. }
  201. enc->context = avcodec_alloc_context3(enc->codec);
  202. if (!enc->context) {
  203. warn("Failed to create codec context");
  204. goto fail;
  205. }
  206. if (codec_desc->props & AV_CODEC_PROP_LOSSLESS)
  207. // Set by encoder on init, not known at this time
  208. enc->context->bit_rate = -1;
  209. else
  210. enc->context->bit_rate = bitrate * 1000;
  211. const struct audio_output_info *aoi;
  212. aoi = audio_output_get_info(audio);
  213. #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(57, 24, 100)
  214. enc->context->channels = (int)audio_output_get_channels(audio);
  215. #endif
  216. #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 24, 100)
  217. enc->context->channel_layout = convert_speaker_layout(aoi->speakers);
  218. #else
  219. av_channel_layout_default(&enc->context->ch_layout,
  220. (int)audio_output_get_channels(audio));
  221. /* The avutil default channel layout for 5 channels is 5.0, which OBS
  222. * does not support. Manually set 5 channels to 4.1. */
  223. if (aoi->speakers == SPEAKERS_4POINT1)
  224. enc->context->ch_layout =
  225. (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT1;
  226. /* AAC, ALAC, & FLAC default to 3.0 for 3 channels instead of 2.1.
  227. * Tell the encoder to deal with 2.1 as if it were 3.0. */
  228. if (aoi->speakers == SPEAKERS_2POINT1)
  229. enc->context->ch_layout =
  230. (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND;
  231. // ALAC supports 7.1 wide instead of regular 7.1.
  232. if (aoi->speakers == SPEAKERS_7POINT1 &&
  233. astrcmpi(enc->type, "alac") == 0)
  234. enc->context->ch_layout =
  235. (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK;
  236. #endif
  237. enc->context->sample_rate = audio_output_get_sample_rate(audio);
  238. if (enc->codec->sample_fmts) {
  239. /* Check if the requested format is actually available for the specified
  240. * encoder. This may not always be the case due to FFmpeg changes or a
  241. * fallback being used (for example, when libopus is unavailable). */
  242. const enum AVSampleFormat *fmt = enc->codec->sample_fmts;
  243. while (*fmt != AV_SAMPLE_FMT_NONE) {
  244. if (*fmt == sample_format) {
  245. enc->context->sample_fmt = *fmt;
  246. break;
  247. }
  248. fmt++;
  249. }
  250. /* Fall back to default if requested format was not found. */
  251. if (enc->context->sample_fmt == AV_SAMPLE_FMT_NONE)
  252. enc->context->sample_fmt = enc->codec->sample_fmts[0];
  253. } else {
  254. /* Fall back to planar float if codec does not specify formats. */
  255. enc->context->sample_fmt = AV_SAMPLE_FMT_FLTP;
  256. }
  257. /* check to make sure sample rate is supported */
  258. if (enc->codec->supported_samplerates) {
  259. const int *rate = enc->codec->supported_samplerates;
  260. int cur_rate = enc->context->sample_rate;
  261. int closest = 0;
  262. while (*rate) {
  263. int dist = abs(cur_rate - *rate);
  264. int closest_dist = abs(cur_rate - closest);
  265. if (dist < closest_dist)
  266. closest = *rate;
  267. rate++;
  268. }
  269. if (closest)
  270. enc->context->sample_rate = closest;
  271. }
  272. #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 24, 100)
  273. info("bitrate: %" PRId64 ", channels: %d, channel_layout: %x\n",
  274. (int64_t)enc->context->bit_rate / 1000,
  275. (int)enc->context->channels,
  276. (unsigned int)enc->context->channel_layout);
  277. #else
  278. char buf[256];
  279. av_channel_layout_describe(&enc->context->ch_layout, buf, 256);
  280. info("bitrate: %" PRId64 ", channels: %d, channel_layout: %s\n",
  281. (int64_t)enc->context->bit_rate / 1000,
  282. (int)enc->context->ch_layout.nb_channels, buf);
  283. #endif
  284. init_sizes(enc, audio);
  285. /* enable experimental FFmpeg encoder if the only one available */
  286. enc->context->strict_std_compliance = -2;
  287. enc->context->flags = AV_CODEC_FLAG_GLOBAL_HEADER;
  288. if (initialize_codec(enc))
  289. return enc;
  290. fail:
  291. enc_destroy(enc);
  292. return NULL;
  293. }
  294. static void *aac_create(obs_data_t *settings, obs_encoder_t *encoder)
  295. {
  296. return enc_create(settings, encoder, "aac", NULL, AV_SAMPLE_FMT_NONE);
  297. }
  298. static void *opus_create(obs_data_t *settings, obs_encoder_t *encoder)
  299. {
  300. return enc_create(settings, encoder, "libopus", "opus",
  301. AV_SAMPLE_FMT_FLT);
  302. }
  303. static void *pcm_create(obs_data_t *settings, obs_encoder_t *encoder)
  304. {
  305. return enc_create(settings, encoder, "pcm_s16le", NULL,
  306. AV_SAMPLE_FMT_NONE);
  307. }
  308. static void *pcm24_create(obs_data_t *settings, obs_encoder_t *encoder)
  309. {
  310. return enc_create(settings, encoder, "pcm_s24le", NULL,
  311. AV_SAMPLE_FMT_NONE);
  312. }
  313. static void *pcm32_create(obs_data_t *settings, obs_encoder_t *encoder)
  314. {
  315. return enc_create(settings, encoder, "pcm_f32le", NULL,
  316. AV_SAMPLE_FMT_NONE);
  317. }
  318. static void *alac_create(obs_data_t *settings, obs_encoder_t *encoder)
  319. {
  320. return enc_create(settings, encoder, "alac", NULL, AV_SAMPLE_FMT_S32P);
  321. }
  322. static void *flac_create(obs_data_t *settings, obs_encoder_t *encoder)
  323. {
  324. return enc_create(settings, encoder, "flac", NULL, AV_SAMPLE_FMT_S16);
  325. }
  326. static bool do_encode(struct enc_encoder *enc, struct encoder_packet *packet,
  327. bool *received_packet)
  328. {
  329. AVRational time_base = {1, enc->context->sample_rate};
  330. AVPacket avpacket = {0};
  331. int got_packet;
  332. int ret;
  333. int channels;
  334. enc->aframe->nb_samples = enc->frame_size;
  335. enc->aframe->pts = av_rescale_q(
  336. enc->total_samples, (AVRational){1, enc->context->sample_rate},
  337. enc->context->time_base);
  338. #if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 24, 100)
  339. enc->aframe->ch_layout = enc->context->ch_layout;
  340. channels = enc->context->ch_layout.nb_channels;
  341. #else
  342. channels = enc->context->channels;
  343. #endif
  344. ret = avcodec_fill_audio_frame(enc->aframe, channels,
  345. enc->context->sample_fmt,
  346. enc->samples[0],
  347. enc->frame_size_bytes * channels, 1);
  348. if (ret < 0) {
  349. warn("avcodec_fill_audio_frame failed: %s", av_err2str(ret));
  350. return false;
  351. }
  352. enc->total_samples += enc->frame_size;
  353. ret = avcodec_send_frame(enc->context, enc->aframe);
  354. if (ret == 0)
  355. ret = avcodec_receive_packet(enc->context, &avpacket);
  356. got_packet = (ret == 0);
  357. if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
  358. ret = 0;
  359. if (ret < 0) {
  360. warn("avcodec_encode_audio2 failed: %s", av_err2str(ret));
  361. return false;
  362. }
  363. *received_packet = !!got_packet;
  364. if (!got_packet)
  365. return true;
  366. da_resize(enc->packet_buffer, 0);
  367. da_push_back_array(enc->packet_buffer, avpacket.data, avpacket.size);
  368. packet->pts = rescale_ts(avpacket.pts, enc->context, time_base);
  369. packet->dts = rescale_ts(avpacket.dts, enc->context, time_base);
  370. packet->data = enc->packet_buffer.array;
  371. packet->size = avpacket.size;
  372. packet->type = OBS_ENCODER_AUDIO;
  373. packet->keyframe = true;
  374. packet->timebase_num = 1;
  375. packet->timebase_den = (int32_t)enc->context->sample_rate;
  376. av_packet_unref(&avpacket);
  377. return true;
  378. }
  379. static bool enc_encode(void *data, struct encoder_frame *frame,
  380. struct encoder_packet *packet, bool *received_packet)
  381. {
  382. struct enc_encoder *enc = data;
  383. for (size_t i = 0; i < enc->audio_planes; i++)
  384. memcpy(enc->samples[i], frame->data[i], enc->frame_size_bytes);
  385. return do_encode(enc, packet, received_packet);
  386. }
  387. static void enc_defaults(obs_data_t *settings)
  388. {
  389. obs_data_set_default_int(settings, "bitrate", 128);
  390. }
  391. static obs_properties_t *enc_properties(void *unused)
  392. {
  393. UNUSED_PARAMETER(unused);
  394. obs_properties_t *props = obs_properties_create();
  395. obs_properties_add_int(props, "bitrate", obs_module_text("Bitrate"), 64,
  396. 1024, 32);
  397. return props;
  398. }
  399. static bool enc_extra_data(void *data, uint8_t **extra_data, size_t *size)
  400. {
  401. struct enc_encoder *enc = data;
  402. *extra_data = enc->context->extradata;
  403. *size = enc->context->extradata_size;
  404. return true;
  405. }
  406. static void enc_audio_info(void *data, struct audio_convert_info *info)
  407. {
  408. struct enc_encoder *enc = data;
  409. int channels;
  410. #if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 24, 100)
  411. channels = enc->context->ch_layout.nb_channels;
  412. #else
  413. channels = enc->context->channels;
  414. #endif
  415. info->format = convert_ffmpeg_sample_format(enc->context->sample_fmt);
  416. info->samples_per_sec = (uint32_t)enc->context->sample_rate;
  417. if (channels != 7 && channels <= 8)
  418. info->speakers = (enum speaker_layout)(channels);
  419. else
  420. info->speakers = SPEAKERS_UNKNOWN;
  421. }
  422. static void enc_audio_info_float(void *data, struct audio_convert_info *info)
  423. {
  424. enc_audio_info(data, info);
  425. info->allow_clipping = true;
  426. }
  427. static size_t enc_frame_size(void *data)
  428. {
  429. struct enc_encoder *enc = data;
  430. return enc->frame_size;
  431. }
  432. struct obs_encoder_info aac_encoder_info = {
  433. .id = "ffmpeg_aac",
  434. .type = OBS_ENCODER_AUDIO,
  435. .codec = "aac",
  436. .get_name = aac_getname,
  437. .create = aac_create,
  438. .destroy = enc_destroy,
  439. .encode = enc_encode,
  440. .get_frame_size = enc_frame_size,
  441. .get_defaults = enc_defaults,
  442. .get_properties = enc_properties,
  443. .get_extra_data = enc_extra_data,
  444. .get_audio_info = enc_audio_info,
  445. };
  446. struct obs_encoder_info opus_encoder_info = {
  447. .id = "ffmpeg_opus",
  448. .type = OBS_ENCODER_AUDIO,
  449. .codec = "opus",
  450. .get_name = opus_getname,
  451. .create = opus_create,
  452. .destroy = enc_destroy,
  453. .encode = enc_encode,
  454. .get_frame_size = enc_frame_size,
  455. .get_defaults = enc_defaults,
  456. .get_properties = enc_properties,
  457. .get_extra_data = enc_extra_data,
  458. .get_audio_info = enc_audio_info,
  459. };
  460. struct obs_encoder_info pcm_encoder_info = {
  461. .id = "ffmpeg_pcm_s16le",
  462. .type = OBS_ENCODER_AUDIO,
  463. .codec = "pcm_s16le",
  464. .get_name = pcm_getname,
  465. .create = pcm_create,
  466. .destroy = enc_destroy,
  467. .encode = enc_encode,
  468. .get_frame_size = enc_frame_size,
  469. .get_defaults = enc_defaults,
  470. .get_properties = enc_properties,
  471. .get_extra_data = enc_extra_data,
  472. .get_audio_info = enc_audio_info,
  473. };
  474. struct obs_encoder_info pcm24_encoder_info = {
  475. .id = "ffmpeg_pcm_s24le",
  476. .type = OBS_ENCODER_AUDIO,
  477. .codec = "pcm_s24le",
  478. .get_name = pcm24_getname,
  479. .create = pcm24_create,
  480. .destroy = enc_destroy,
  481. .encode = enc_encode,
  482. .get_frame_size = enc_frame_size,
  483. .get_defaults = enc_defaults,
  484. .get_properties = enc_properties,
  485. .get_extra_data = enc_extra_data,
  486. .get_audio_info = enc_audio_info,
  487. };
  488. struct obs_encoder_info pcm32_encoder_info = {
  489. .id = "ffmpeg_pcm_f32le",
  490. .type = OBS_ENCODER_AUDIO,
  491. .codec = "pcm_f32le",
  492. .get_name = pcm32_getname,
  493. .create = pcm32_create,
  494. .destroy = enc_destroy,
  495. .encode = enc_encode,
  496. .get_frame_size = enc_frame_size,
  497. .get_defaults = enc_defaults,
  498. .get_properties = enc_properties,
  499. .get_extra_data = enc_extra_data,
  500. .get_audio_info = enc_audio_info_float,
  501. };
  502. struct obs_encoder_info alac_encoder_info = {
  503. .id = "ffmpeg_alac",
  504. .type = OBS_ENCODER_AUDIO,
  505. .codec = "alac",
  506. .get_name = alac_getname,
  507. .create = alac_create,
  508. .destroy = enc_destroy,
  509. .encode = enc_encode,
  510. .get_frame_size = enc_frame_size,
  511. .get_defaults = enc_defaults,
  512. .get_properties = enc_properties,
  513. .get_extra_data = enc_extra_data,
  514. .get_audio_info = enc_audio_info,
  515. };
  516. struct obs_encoder_info flac_encoder_info = {
  517. .id = "ffmpeg_flac",
  518. .type = OBS_ENCODER_AUDIO,
  519. .codec = "flac",
  520. .get_name = flac_getname,
  521. .create = flac_create,
  522. .destroy = enc_destroy,
  523. .encode = enc_encode,
  524. .get_frame_size = enc_frame_size,
  525. .get_defaults = enc_defaults,
  526. .get_properties = enc_properties,
  527. .get_extra_data = enc_extra_data,
  528. .get_audio_info = enc_audio_info,
  529. };