| 364 | } |
| 365 | |
| 366 | int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, |
| 367 | enum AVSampleFormat sample_fmt, const uint8_t *buf, |
| 368 | int buf_size, int align) |
| 369 | { |
| 370 | int ch, planar, needed_size, ret = 0; |
| 371 | |
| 372 | needed_size = av_samples_get_buffer_size(NULL, nb_channels, |
| 373 | frame->nb_samples, sample_fmt, |
| 374 | align); |
| 375 | if (buf_size < needed_size) |
| 376 | return AVERROR(EINVAL); |
| 377 | |
| 378 | planar = av_sample_fmt_is_planar(sample_fmt); |
| 379 | if (planar && nb_channels > AV_NUM_DATA_POINTERS) { |
| 380 | if (!FF_ALLOCZ_TYPED_ARRAY(frame->extended_data, nb_channels)) |
| 381 | return AVERROR(ENOMEM); |
| 382 | } else { |
| 383 | frame->extended_data = frame->data; |
| 384 | } |
| 385 | |
| 386 | if ((ret = av_samples_fill_arrays(frame->extended_data, &frame->linesize[0], |
| 387 | (uint8_t *)(intptr_t)buf, nb_channels, frame->nb_samples, |
| 388 | sample_fmt, align)) < 0) { |
| 389 | if (frame->extended_data != frame->data) |
| 390 | av_freep(&frame->extended_data); |
| 391 | return ret; |
| 392 | } |
| 393 | if (frame->extended_data != frame->data) { |
| 394 | for (ch = 0; ch < AV_NUM_DATA_POINTERS; ch++) |
| 395 | frame->data[ch] = frame->extended_data[ch]; |
| 396 | } |
| 397 | |
| 398 | return ret; |
| 399 | } |
| 400 | |
| 401 | |
| 402 | int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec){ |
nothing calls this directly
no test coverage detected