| 2304 | } |
| 2305 | |
| 2306 | static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, |
| 2307 | int *decode_failed) |
| 2308 | { |
| 2309 | AVFrame *decoded_frame; |
| 2310 | AVCodecContext *avctx = ist->dec_ctx; |
| 2311 | int ret, err = 0; |
| 2312 | AVRational decoded_frame_tb; |
| 2313 | |
| 2314 | if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) |
| 2315 | return AVERROR(ENOMEM); |
| 2316 | if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc())) |
| 2317 | return AVERROR(ENOMEM); |
| 2318 | decoded_frame = ist->decoded_frame; |
| 2319 | |
| 2320 | update_benchmark(NULL); |
| 2321 | ret = decode(avctx, decoded_frame, got_output, pkt); |
| 2322 | update_benchmark("decode_audio %d.%d", ist->file_index, ist->st->index); |
| 2323 | if (ret < 0) |
| 2324 | *decode_failed = 1; |
| 2325 | |
| 2326 | if (ret >= 0 && avctx->sample_rate <= 0) { |
| 2327 | av_log(avctx, AV_LOG_ERROR, "Sample rate %d invalid\n", avctx->sample_rate); |
| 2328 | ret = AVERROR_INVALIDDATA; |
| 2329 | } |
| 2330 | |
| 2331 | if (ret != AVERROR_EOF) |
| 2332 | check_decode_result(ist, got_output, ret); |
| 2333 | |
| 2334 | if (!*got_output || ret < 0) |
| 2335 | return ret; |
| 2336 | |
| 2337 | ist->samples_decoded += decoded_frame->nb_samples; |
| 2338 | ist->frames_decoded++; |
| 2339 | |
| 2340 | #if 1 |
| 2341 | /* increment next_dts to use for the case where the input stream does not |
| 2342 | have timestamps or there are multiple frames in the packet */ |
| 2343 | ist->next_pts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) / |
| 2344 | avctx->sample_rate; |
| 2345 | ist->next_dts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) / |
| 2346 | avctx->sample_rate; |
| 2347 | #endif |
| 2348 | |
| 2349 | if (decoded_frame->pts != AV_NOPTS_VALUE) { |
| 2350 | decoded_frame_tb = ist->st->time_base; |
| 2351 | } else if (pkt && pkt->pts != AV_NOPTS_VALUE) { |
| 2352 | decoded_frame->pts = pkt->pts; |
| 2353 | decoded_frame_tb = ist->st->time_base; |
| 2354 | }else { |
| 2355 | decoded_frame->pts = ist->dts; |
| 2356 | decoded_frame_tb = AV_TIME_BASE_Q; |
| 2357 | } |
| 2358 | if (decoded_frame->pts != AV_NOPTS_VALUE) |
| 2359 | decoded_frame->pts = av_rescale_delta(decoded_frame_tb, decoded_frame->pts, |
| 2360 | (AVRational){1, avctx->sample_rate}, decoded_frame->nb_samples, &ist->filter_in_rescale_delta_last, |
| 2361 | (AVRational){1, avctx->sample_rate}); |
| 2362 | ist->nb_samples = decoded_frame->nb_samples; |
| 2363 | err = send_frame_to_filters(ist, decoded_frame); |
no test coverage detected