From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 13/14] avcodec/flac_parse: Use void* instead of AVCodecContext* as logctx Date: Thu, 28 Sep 2023 23:35:47 +0200 Message-ID: <AS8P250MB074462EDECA9DF8A4EDD22C98FC1A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <AS8P250MB0744136FB53B9E573DD249D68FC1A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> It more directly shows that ff_flac_decode_frame_header() does not modify the AVCodecContext given to it at all; and it would not be allowed to do so, given that it is used by the parser when it is still unknown whether said frame header is even valid. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/flac.c | 18 +++++++++--------- libavcodec/flac_parse.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libavcodec/flac.c b/libavcodec/flac.c index 174b4801be..fac4cff9e7 100644 --- a/libavcodec/flac.c +++ b/libavcodec/flac.c @@ -48,14 +48,14 @@ static int64_t get_utf8(GetBitContext *gb) return val; } -int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, +int ff_flac_decode_frame_header(void *logctx, GetBitContext *gb, FLACFrameInfo *fi, int log_level_offset) { int bs_code, sr_code, bps_code; /* frame sync code */ if ((get_bits(gb, 15) & 0x7FFF) != 0x7FFC) { - av_log(avctx, AV_LOG_ERROR + log_level_offset, "invalid sync code\n"); + av_log(logctx, AV_LOG_ERROR + log_level_offset, "invalid sync code\n"); return AVERROR_INVALIDDATA; } @@ -75,7 +75,7 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, fi->channels = 2; fi->ch_mode -= FLAC_MAX_CHANNELS - 1; } else { - av_log(avctx, AV_LOG_ERROR + log_level_offset, + av_log(logctx, AV_LOG_ERROR + log_level_offset, "invalid channel mode: %d\n", fi->ch_mode); return AVERROR_INVALIDDATA; } @@ -83,7 +83,7 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, /* bits per sample */ bps_code = get_bits(gb, 3); if (bps_code == 3) { - av_log(avctx, AV_LOG_ERROR + log_level_offset, + av_log(logctx, AV_LOG_ERROR + log_level_offset, "invalid sample size code (%d)\n", bps_code); return AVERROR_INVALIDDATA; @@ -92,7 +92,7 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, /* reserved bit */ if (get_bits1(gb)) { - av_log(avctx, AV_LOG_ERROR + log_level_offset, + av_log(logctx, AV_LOG_ERROR + log_level_offset, "broken stream, invalid padding\n"); return AVERROR_INVALIDDATA; } @@ -100,14 +100,14 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, /* sample or frame count */ fi->frame_or_sample_num = get_utf8(gb); if (fi->frame_or_sample_num < 0) { - av_log(avctx, AV_LOG_ERROR + log_level_offset, + av_log(logctx, AV_LOG_ERROR + log_level_offset, "sample/frame number invalid; utf8 fscked\n"); return AVERROR_INVALIDDATA; } /* blocksize */ if (bs_code == 0) { - av_log(avctx, AV_LOG_ERROR + log_level_offset, + av_log(logctx, AV_LOG_ERROR + log_level_offset, "reserved blocksize code: 0\n"); return AVERROR_INVALIDDATA; } else if (bs_code == 6) { @@ -128,7 +128,7 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, } else if (sr_code == 14) { fi->samplerate = get_bits(gb, 16) * 10; } else { - av_log(avctx, AV_LOG_ERROR + log_level_offset, + av_log(logctx, AV_LOG_ERROR + log_level_offset, "illegal sample rate code %d\n", sr_code); return AVERROR_INVALIDDATA; @@ -138,7 +138,7 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, skip_bits(gb, 8); if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer, get_bits_count(gb)/8)) { - av_log(avctx, AV_LOG_ERROR + log_level_offset, + av_log(logctx, AV_LOG_ERROR + log_level_offset, "header crc mismatch\n"); return AVERROR_INVALIDDATA; } diff --git a/libavcodec/flac_parse.h b/libavcodec/flac_parse.h index 67a7320bea..b0cbad825e 100644 --- a/libavcodec/flac_parse.h +++ b/libavcodec/flac_parse.h @@ -75,13 +75,13 @@ int ff_flac_is_extradata_valid(AVCodecContext *avctx, /** * Validate and decode a frame header. - * @param avctx AVCodecContext to use as av_log() context + * @param logctx context for logging * @param gb GetBitContext from which to read frame header * @param[out] fi frame information * @param log_level_offset log level offset. can be used to silence error messages. * @return non-zero on error, 0 if ok */ -int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, +int ff_flac_decode_frame_header(void *logctx, GetBitContext *gb, FLACFrameInfo *fi, int log_level_offset); void ff_flac_set_channel_layout(AVCodecContext *avctx, int channels); -- 2.34.1 _______________________________________________ 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-09-28 21:36 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-28 21:32 [FFmpeg-devel] [PATCH 01/14] configure: Remove obsolete wmavoice->rdft, dct dependencies Andreas Rheinhardt 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 02/14] configure: Remove obsolete ffplay->rdft dependency Andreas Rheinhardt 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 03/14] configure: Remove unnecessary vf_spp->fft dependency Andreas Rheinhardt 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 04/14] avcodec/mpegaudiodsp: Init dct32 directly Andreas Rheinhardt 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 06/14] configure: Remove dct, fft, mdct, rdft subsystems Andreas Rheinhardt 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 07/14] avcodec/vorbis: Use void* logctx instead of AVCodecContext* Andreas Rheinhardt 2023-09-30 10:28 ` Andreas Rheinhardt 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 08/14] avcodec/utvideo: Split UTvideoContext into decoder and encoder contexts Andreas Rheinhardt 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 09/14] avcodec/sipr: Remove write-only AVCodecContext* Andreas Rheinhardt 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 10/14] avcodec/roqvideo: Use void*, not AVCodecContext* for logctx Andreas Rheinhardt 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 11/14] avcodec/opus_silk: Use void* instead of AVCodecContext* as logctx Andreas Rheinhardt 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 12/14] avcodec/lagarith: " Andreas Rheinhardt 2023-09-28 21:35 ` Andreas Rheinhardt [this message] 2023-09-28 21:35 ` [FFmpeg-devel] [PATCH 14/14] avcodec/bgmc: " Andreas Rheinhardt 2023-09-28 21:42 ` [FFmpeg-devel] [PATCH 01/14] configure: Remove obsolete wmavoice->rdft, dct dependencies Andreas Rheinhardt 2023-09-28 21:59 ` Lynne 2023-09-28 22:11 ` Andreas Rheinhardt 2023-09-28 23:26 ` Lynne
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=AS8P250MB074462EDECA9DF8A4EDD22C98FC1A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.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