| 2507 | } |
| 2508 | |
| 2509 | static void decodeAudio(hb_work_private_t *pv, packet_info_t * packet_info) |
| 2510 | { |
| 2511 | AVCodecContext * context = pv->context; |
| 2512 | AVPacket * avp = pv->pkt; |
| 2513 | int ret; |
| 2514 | |
| 2515 | // libav does not supply timestamps for wmapro audio (possibly others) |
| 2516 | // if there is an input timestamp, initialize next_pts |
| 2517 | if (pv->next_pts == (int64_t)AV_NOPTS_VALUE && |
| 2518 | packet_info != NULL && |
| 2519 | packet_info->pts != AV_NOPTS_VALUE) |
| 2520 | { |
| 2521 | pv->next_pts = packet_info->pts; |
| 2522 | } |
| 2523 | if (packet_info != NULL) |
| 2524 | { |
| 2525 | avp->data = packet_info->data; |
| 2526 | avp->size = packet_info->size; |
| 2527 | avp->pts = packet_info->pts; |
| 2528 | avp->dts = AV_NOPTS_VALUE; |
| 2529 | avp->flags |= packet_info->discard * AV_PKT_FLAG_DISCARD; |
| 2530 | } |
| 2531 | else |
| 2532 | { |
| 2533 | avp->data = NULL; |
| 2534 | avp->size = 0; |
| 2535 | } |
| 2536 | |
| 2537 | ret = avcodec_send_packet(context, avp); |
| 2538 | if (ret < 0 && ret != AVERROR_EOF) |
| 2539 | { |
| 2540 | av_packet_unref(avp); |
| 2541 | return; |
| 2542 | } |
| 2543 | |
| 2544 | do |
| 2545 | { |
| 2546 | ret = avcodec_receive_frame(context, pv->frame); |
| 2547 | if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) |
| 2548 | { |
| 2549 | ++pv->decode_errors; |
| 2550 | } |
| 2551 | if (ret < 0) |
| 2552 | { |
| 2553 | break; |
| 2554 | } |
| 2555 | |
| 2556 | hb_buffer_t * out; |
| 2557 | int samplerate; |
| 2558 | |
| 2559 | // libavcoded doesn't yet consistently set frame->sample_rate |
| 2560 | if (pv->frame->sample_rate != 0) |
| 2561 | { |
| 2562 | samplerate = pv->frame->sample_rate; |
| 2563 | } |
| 2564 | else |
| 2565 | { |
| 2566 | samplerate = context->sample_rate; |
no test coverage detected