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

Function seek_test

tests/api/api-seek-test.c:186–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186static int seek_test(const char *input_filename, const char *start, const char *end)
187{
188 const AVCodec *codec = NULL;
189 AVCodecContext *ctx= NULL;
190 AVCodecParameters *origin_par = NULL;
191 AVPacket *pkt = NULL;
192 AVFrame *fr = NULL;
193 AVFormatContext *fmt_ctx = NULL;
194 int video_stream;
195 int result;
196 int i, j;
197 long int start_ts, end_ts;
198
199 size_of_array = 0;
200 number_of_elements = 0;
201 crc_array = NULL;
202 pts_array = NULL;
203
204 result = avformat_open_input(&fmt_ctx, input_filename, NULL, NULL);
205 if (result < 0) {
206 av_log(NULL, AV_LOG_ERROR, "Can't open file\n");
207 return result;
208 }
209
210 result = avformat_find_stream_info(fmt_ctx, NULL);
211 if (result < 0) {
212 av_log(NULL, AV_LOG_ERROR, "Can't get stream info\n");
213 goto end;
214 }
215
216 start_ts = read_seek_range(start);
217 end_ts = read_seek_range(end);
218 if ((start_ts < 0) || (end_ts < 0)) {
219 result = -1;
220 goto end;
221 }
222
223 //TODO: add ability to work with audio format
224 video_stream = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
225 if (video_stream < 0) {
226 av_log(NULL, AV_LOG_ERROR, "Can't find video stream in input file\n");
227 result = video_stream;
228 goto end;
229 }
230
231 origin_par = fmt_ctx->streams[video_stream]->codecpar;
232
233 codec = avcodec_find_decoder(origin_par->codec_id);
234 if (!codec) {
235 av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n");
236 result = AVERROR_DECODER_NOT_FOUND;
237 goto end;
238 }
239
240 ctx = avcodec_alloc_context3(codec);
241 if (!ctx) {
242 av_log(NULL, AV_LOG_ERROR, "Can't allocate decoder context\n");
243 result = AVERROR(ENOMEM);

Callers 1

mainFunction · 0.85

Calls 15

avformat_open_inputFunction · 0.85
av_logFunction · 0.85
read_seek_rangeFunction · 0.85
av_find_best_streamFunction · 0.85
avcodec_find_decoderFunction · 0.85
avcodec_alloc_context3Function · 0.85
avcodec_open2Function · 0.85
av_frame_allocFunction · 0.85
av_packet_allocFunction · 0.85
compute_crc_of_packetsFunction · 0.85

Tested by

no test coverage detected