* Initialize a temporary storage for the specified number of audio samples. * The conversion requires temporary storage due to the different format. * The number of audio samples to be allocated is specified in frame_size. * @param[out] converted_input_samples Array of converted samples. The * dimensions are reference, channel *
| 442 | * @return Error code (0 if successful) |
| 443 | */ |
| 444 | static int init_converted_samples(uint8_t ***converted_input_samples, |
| 445 | AVCodecContext *output_codec_context, |
| 446 | int frame_size) |
| 447 | { |
| 448 | int error; |
| 449 | |
| 450 | /* Allocate as many pointers as there are audio channels. |
| 451 | * Each pointer will point to the audio samples of the corresponding |
| 452 | * channels (although it may be NULL for interleaved formats). |
| 453 | * Allocate memory for the samples of all channels in one consecutive |
| 454 | * block for convenience. */ |
| 455 | if ((error = av_samples_alloc_array_and_samples(converted_input_samples, NULL, |
| 456 | output_codec_context->ch_layout.nb_channels, |
| 457 | frame_size, |
| 458 | output_codec_context->sample_fmt, 0)) < 0) { |
| 459 | fprintf(stderr, |
| 460 | "Could not allocate converted input samples (error '%s')\n", |
| 461 | av_err2str(error)); |
| 462 | return error; |
| 463 | } |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * Convert the input audio samples into the output sample format. |
no test coverage detected