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

Function run_test

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

Source from the content-addressed store, hash-verified

106}
107
108static int run_test(const AVCodec *enc, const AVCodec *dec,
109 AVCodecContext *enc_ctx, AVCodecContext *dec_ctx)
110{
111 AVPacket *enc_pkt;
112 AVFrame *in_frame, *out_frame;
113 uint8_t *raw_in = NULL, *raw_out = NULL;
114 int in_offset = 0, out_offset = 0;
115 int result = 0;
116 int i = 0;
117 int in_frame_bytes, out_frame_bytes;
118
119 enc_pkt = av_packet_alloc();
120 if (!enc_pkt) {
121 av_log(NULL, AV_LOG_ERROR, "Can't allocate output packet\n");
122 return AVERROR(ENOMEM);
123 }
124
125 in_frame = av_frame_alloc();
126 if (!in_frame) {
127 av_log(NULL, AV_LOG_ERROR, "Can't allocate input frame\n");
128 return AVERROR(ENOMEM);
129 }
130
131 in_frame->nb_samples = enc_ctx->frame_size;
132 in_frame->format = enc_ctx->sample_fmt;
133 result = av_channel_layout_copy(&in_frame->ch_layout, &enc_ctx->ch_layout);
134 if (result < 0)
135 return result;
136 if (av_frame_get_buffer(in_frame, 0) != 0) {
137 av_log(NULL, AV_LOG_ERROR, "Can't allocate a buffer for input frame\n");
138 return AVERROR(ENOMEM);
139 }
140
141 out_frame = av_frame_alloc();
142 if (!out_frame) {
143 av_log(NULL, AV_LOG_ERROR, "Can't allocate output frame\n");
144 return AVERROR(ENOMEM);
145 }
146
147 raw_in = av_malloc(in_frame->linesize[0] * NUMBER_OF_AUDIO_FRAMES);
148 if (!raw_in) {
149 av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_in\n");
150 return AVERROR(ENOMEM);
151 }
152
153 raw_out = av_malloc(in_frame->linesize[0] * NUMBER_OF_AUDIO_FRAMES);
154 if (!raw_out) {
155 av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_out\n");
156 return AVERROR(ENOMEM);
157 }
158
159 for (i = 0; i < NUMBER_OF_AUDIO_FRAMES; i++) {
160 result = av_frame_make_writable(in_frame);
161 if (result < 0)
162 return result;
163
164 generate_raw_frame((uint16_t*)(in_frame->data[0]), i, enc_ctx->sample_rate,
165 enc_ctx->ch_layout.nb_channels, enc_ctx->frame_size);

Callers 1

mainFunction · 0.70

Calls 15

av_packet_allocFunction · 0.85
av_logFunction · 0.85
av_frame_allocFunction · 0.85
av_channel_layout_copyFunction · 0.85
av_frame_get_bufferFunction · 0.85
av_frame_make_writableFunction · 0.85
generate_raw_frameFunction · 0.85
avcodec_send_frameFunction · 0.85
avcodec_receive_packetFunction · 0.85
avcodec_send_packetFunction · 0.85
av_packet_unrefFunction · 0.85
avcodec_receive_frameFunction · 0.85

Tested by

no test coverage detected