From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] RK Audio demuxer and decoder
Date: Wed, 15 Feb 2023 08:59:43 -0300
Message-ID: <eb574658-215b-3ce7-8bde-b897f2fb3f56@gmail.com> (raw)
In-Reply-To: <CAPYw7P7b+nghh7c64KYPzJnBFtfOGbwpCSU-X527UWMpt-StWw@mail.gmail.com>
On 2/5/2023 4:17 PM, Paul B Mahol wrote:
> On 2/4/23, Paul B Mahol <onemda@gmail.com> wrote:
>> Hi,
>>
>> Patches attached, decoder is not bit by bit exact yet for lossless
>> mode because some samples are not properly rounded.
>>
>
> Now lossless mode is bit exact.
[...]
> +static av_cold int rka_decode_init(AVCodecContext *avctx)
> +{
> + RKAContext *s = avctx->priv_data;
> + int cmode;
> +
> + if (avctx->extradata_size < 16)
> + return AVERROR_INVALIDDATA;
> +
> + s->bps = avctx->bits_per_raw_sample = avctx->extradata[13];
> +
> + switch (s->bps) {
> + case 8:
> + avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
> + break;
> + case 16:
> + avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
> + break;
> + default:
> + return AVERROR_INVALIDDATA;
> + }
> +
> + s->channels = avctx->ch_layout.nb_channels;
You're ignoring the channels reported by the extradata despite flagging
this decoder as AV_CODEC_CAP_CHANNEL_CONF. It should be the other way
around, and ignore the user set layout, if any, with
av_channel_layout_uninit(&avctx->ch_layout);
s->channels = avctx->ch_layout.nb_channels = avctx->extradata[12];
Because the stream may not necessarily come from the lavf demuxer.
Extradata presence is required given you check for it above, but the
avctx fields could be set to whatever if the source is not the lavf rka
demuxer.
> + if (s->channels < 1 || s->channels > 2)
> + return AVERROR_INVALIDDATA;
> +
> + s->align = (s->channels * (avctx->bits_per_raw_sample >> 3));
> + s->samples_left = s->total_nb_samples = (AV_RL32(avctx->extradata + 4)) / s->align;
> + s->frame_samples = 131072 / s->align;
> + s->last_nb_samples = s->total_nb_samples % s->frame_samples;
> +
> + cmode = avctx->extradata[14] & 0xf;
> + if ((avctx->extradata[15] & 4) != 0)
> + cmode = -cmode;
> +
> + s->ch[0].cmode = s->ch[1].cmode = cmode;
> + s->ch[0].cmode2 = -s->ch[0].cmode;
> + s->ch[1].cmode2 = -s->ch[1].cmode;
> + av_log(avctx, AV_LOG_DEBUG, "cmode: %d\n", cmode);
> +
> + return 0;
> +}
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2023-02-15 11:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-04 9:04 [FFmpeg-devel] [RFC][WIP][PATCH] " Paul B Mahol
2023-02-05 19:17 ` [FFmpeg-devel] [PATCH] " Paul B Mahol
2023-02-10 18:13 ` Paul B Mahol
2023-02-15 11:59 ` James Almer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb574658-215b-3ce7-8bde-b897f2fb3f56@gmail.com \
--to=jamrial@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git