MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / init_encoder

Function init_encoder

tests/api/api-flac-test.c:53–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53static int init_encoder(const AVCodec *enc, AVCodecContext **enc_ctx,
54 const AVChannelLayout *ch_layout, int sample_rate)
55{
56 AVCodecContext *ctx;
57 int result;
58 char name_buff[NAME_BUFF_SIZE];
59
60 av_channel_layout_describe(ch_layout, name_buff, NAME_BUFF_SIZE);
61 av_log(NULL, AV_LOG_INFO, "channel layout: %s, sample rate: %i\n", name_buff, sample_rate);
62
63 ctx = avcodec_alloc_context3(enc);
64 if (!ctx) {
65 av_log(NULL, AV_LOG_ERROR, "Can't allocate encoder context\n");
66 return AVERROR(ENOMEM);
67 }
68
69 ctx->sample_fmt = AV_SAMPLE_FMT_S16;
70 ctx->sample_rate = sample_rate;
71 av_channel_layout_copy(&ctx->ch_layout, ch_layout);
72
73 result = avcodec_open2(ctx, enc, NULL);
74 if (result < 0) {
75 av_log(ctx, AV_LOG_ERROR, "Can't open encoder\n");
76 return result;
77 }
78
79 *enc_ctx = ctx;
80 return 0;
81}
82
83static int init_decoder(const AVCodec *dec, AVCodecContext **dec_ctx,
84 const AVChannelLayout *ch_layout)

Callers 1

mainFunction · 0.85

Calls 5

av_logFunction · 0.85
avcodec_alloc_context3Function · 0.85
av_channel_layout_copyFunction · 0.85
avcodec_open2Function · 0.85

Tested by

no test coverage detected