dfpw: convert to new channel layout API

This commit is contained in:
James Almer 2022-03-10 10:57:39 -03:00
parent b2af4bc807
commit 441fe2508d
2 changed files with 3 additions and 3 deletions

View File

@ -83,7 +83,7 @@ static av_cold int dfpwm_dec_init(struct AVCodecContext *ctx)
{ {
DFPWMState *state = ctx->priv_data; DFPWMState *state = ctx->priv_data;
if (ctx->channels <= 0) { if (ctx->ch_layout.nb_channels <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid number of channels\n"); av_log(ctx, AV_LOG_ERROR, "Invalid number of channels\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
@ -106,7 +106,7 @@ static int dfpwm_dec_frame(struct AVCodecContext *ctx, void *data,
AVFrame *frame = data; AVFrame *frame = data;
int ret; int ret;
frame->nb_samples = packet->size * 8 / ctx->channels; frame->nb_samples = packet->size * 8 / ctx->ch_layout.nb_channels;
if (frame->nb_samples <= 0) { if (frame->nb_samples <= 0) {
av_log(ctx, AV_LOG_ERROR, "invalid number of samples in packet\n"); av_log(ctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;

View File

@ -93,7 +93,7 @@ static int dfpwm_enc_frame(struct AVCodecContext *ctx, struct AVPacket *packet,
const struct AVFrame *frame, int *got_packet) const struct AVFrame *frame, int *got_packet)
{ {
DFPWMState *state = ctx->priv_data; DFPWMState *state = ctx->priv_data;
int size = frame->nb_samples * frame->channels / 8 + (frame->nb_samples % 8 > 0 ? 1 : 0); int size = frame->nb_samples * frame->ch_layout.nb_channels / 8 + (frame->nb_samples % 8 > 0 ? 1 : 0);
int ret = ff_get_encode_buffer(ctx, packet, size, 0); int ret = ff_get_encode_buffer(ctx, packet, size, 0);
if (ret) { if (ret) {