From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] OSQ lossless audio format support Date: Thu, 24 Aug 2023 16:54:28 -0300 Message-ID: <7a88e877-5697-80fa-924d-0b0175643804@gmail.com> (raw) In-Reply-To: <CAPYw7P7KFPnK3aBba7N0UCsgegT+N3T28bjH19AYc82wh1vg9g@mail.gmail.com> On 8/24/2023 6:52 AM, Paul B Mahol wrote: > Patches attached. > > Stereo decoding have some issues with some predictors so not yet bitexact. > > Please comment. > +static av_cold int osq_close(AVCodecContext *avctx) > +{ > + OSQContext *s = avctx->priv_data; > + > + av_freep(&s->bitstream); > + s->bitstream_size = 0; > + > + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) FFMIN(avctx->ch_layout.nb_channels, 2); This being a FF_CODEC_CAP_INIT_CLEANUP decoder, osq_close() could be called before osq_init() has a chance to validate nb_channels. > + av_freep(&s->decode_buffer[ch]); > + > + return 0; > +} > + > static av_cold int osq_init(AVCodecContext *avctx) > +{ > + OSQContext *s = avctx->priv_data; > + > + if (avctx->extradata_size < 48) > + return AVERROR(EINVAL); > + > + if (avctx->extradata[0] != 1) { > + av_log(avctx, AV_LOG_ERROR, "Unsupported version.\n"); > + return AVERROR_INVALIDDATA; > + } > + > + avctx->sample_rate = AV_RL32(avctx->extradata + 4); > + if (avctx->sample_rate < 1) > + return AVERROR_INVALIDDATA; > + > + avctx->ch_layout.nb_channels = avctx->extradata[3]; You'd need to uninit ch_layout first, as the user may have filled it with something (as is the case with the lavf demuxer). > + if (avctx->ch_layout.nb_channels < 1) > + return AVERROR_INVALIDDATA; > + > + switch (avctx->extradata[2]) { > + case 8: avctx->sample_fmt = AV_SAMPLE_FMT_U8P; break; > + case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break; > + case 20: > + case 24: > + case 28: > + case 32: avctx->sample_fmt = AV_SAMPLE_FMT_S32P; break; > + default: return AVERROR_INVALIDDATA; > + } > + > + s->nb_samples = AV_RL64(avctx->extradata + 16); > + s->frame_samples = AV_RL16(avctx->extradata + 8); > + s->max_framesize = (s->frame_samples * 16 + 1024) * avctx->ch_layout.nb_channels; Do you even need to propagate this header using extradata? You can set codecpar's sample_fmt and frame_size in the demuxer, much like you're doing for sample_rate and ch_layout. There doesn't seem to be a value that can't be propagated using the proper existing fields here. > + > + s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream)); av_mallocz(). sizeof(*s->bitstream) is 1. > + if (!s->bitstream) > + return AVERROR(ENOMEM); > + > + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { > + s->decode_buffer[ch] = av_calloc(s->frame_samples + 4, > + sizeof(*s->decode_buffer[ch])); > + if (!s->decode_buffer[ch]) > + return AVERROR(ENOMEM); > + } > + > + s->pkt = avctx->internal->in_pkt; > + > + 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".
next prev parent reply other threads:[~2023-08-24 19:54 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-08-24 9:52 Paul B Mahol 2023-08-24 18:06 ` Michael Niedermayer 2023-08-24 19:04 ` Paul B Mahol 2023-08-24 19:54 ` James Almer [this message] 2023-08-24 20:09 ` Andreas Rheinhardt 2023-08-24 20:33 ` Paul B Mahol 2023-08-24 21:00 ` James Almer 2023-08-24 21:11 ` Paul B Mahol 2023-08-24 21:51 ` James Almer 2023-08-24 22:06 ` Paul B Mahol 2023-08-25 15:57 ` James Almer 2023-08-25 16:28 ` Paul B Mahol 2023-08-25 16:42 ` James Almer 2023-08-25 17:13 ` Paul B Mahol 2023-08-29 21:25 ` Paul B Mahol 2023-08-29 22:20 ` Andreas Rheinhardt 2023-08-31 17:51 ` Paul B Mahol
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=7a88e877-5697-80fa-924d-0b0175643804@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