From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id BB37F4F7EF for ; Mon, 23 Jun 2025 13:42:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id C8E3F68E284; Mon, 23 Jun 2025 16:39:17 +0300 (EEST) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 7F84768E252 for ; Mon, 23 Jun 2025 16:39:16 +0300 (EEST) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-23649faf69fso41387565ad.0 for ; Mon, 23 Jun 2025 06:39:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750685955; x=1751290755; darn=ffmpeg.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:from:to:cc:subject:date :message-id:reply-to; bh=ZMSVqSYhmpGMj1KCsrYNA+EnhqyDqiocBTPjyWDSNEI=; b=HQLUwX4WaUJs1/R4070hEWmiFPLDyJsNocfOvITNt5GdFF9PZfPWyjoWX4hbh59sab InUg6Yyg23aS3lSUaSJ6knISGyV+LdO1W+So+rQ4tVq2sUVRWRere/FZzkyHsy62CVCz 3ahxZ4kDnLf5Ah94G09w5pqNJFTNnzHFcB4w5+xx72H2U7MIuPu1u3UGC1FUUC4GZH1n vG4p64e1Ohie/AcAOHuid0ll027Yl1gsMMjXuD+QC97om8N/pexe/tVie3gCxTdGvq8o MLCUkbDd+1yzs6xERxSD4t904z97DApKtrCJb22n140X9667EPGNdWBwS8fRuW8Q7Iue jBVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750685955; x=1751290755; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=ZMSVqSYhmpGMj1KCsrYNA+EnhqyDqiocBTPjyWDSNEI=; b=h3IrSI3fy38spoM6HH1ZYjeGwsLlVfeoENt6sKWOnZM6iqtcZ8f8HTSrNA9OlKAPwt 5TX0EskIcfOUlNNkWO+SZ1vnZv0KYeBD3m/XTktl5mjCh1sBcuw6FhtC7o0YUIyChAFh ZjzRmr6/pInetW2tiD97O4Guh4qrS95sJoGewZT51MToC4OUA6K7omS6rUADz8juVDac 1bbUM3lMlL5Fnt2bcstgFY5abGVnCAuvVonwX1PMWMkDM3iM7mm/6MOCy3M4MekpyxW8 5z7JWvzvBwvrqwjLuLAyf+Ll6zwXL/CzzqqoI9Pi7HrhGM8bk3vknG3AY44JhN6EdBIc 0Slg== X-Gm-Message-State: AOJu0Yw8t2mkfUn9Je5Joaa5W325NqlGKB4uaIYWyrDKYgQusE7PB2Oz CQ/Zz6DuwyG+o7mfveOEft4cFWNuUOf82zY4dOENhRSRwMhNqVW0djJE4CkBAA== X-Gm-Gg: ASbGncsRUg9xO0H6+JLCYFPCkqtx66InjsWRXpV7ogvLOHHARjme4K7X8S+CMTCqKy3 2d0WApeLLBGL9HWXqrGcyPFnJPurroO+BCTl/ErvqYZ9ZUJoK1EYiHGQrHbP+00mRqJ0jYTbmoN loE4Nvkd5Ven4b3jx6fGNyrB4JvQY0aLH5H9hmRQAQECZ6I3U4kyoeW5i7u2xCTuufn5Jn1C9fq lGggOgHKwFrvAnAOY5ewM3l02vr8+Pzwv4hd4F9u7lFDR+1V282BrcbDtjnZ0NB+i8TCWDMreB6 aKJAzJREeeYRdoRtHGnloDJt63o4SkjuVJumOs7I3CCnhZPX0ao26gb83DxDtAxc9V7N3zqq62j cN1V+Ic1eKz1G8CbJ X-Google-Smtp-Source: AGHT+IHNplwCN+S8ZY0xP7Z0UNzhVOsUzuOWQK5b+x5p6xNybWGOXHdlrUzrLuih7MjDfbG6hdDDgQ== X-Received: by 2002:a17:903:2306:b0:234:d7b2:2ac4 with SMTP id d9443c01a7336-237d980da56mr217872085ad.17.1750685954513; Mon, 23 Jun 2025 06:39:14 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-237d869c5a1sm83566945ad.192.2025.06.23.06.39.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jun 2025 06:39:14 -0700 (PDT) From: Andreas Rheinhardt X-Google-Original-From: Andreas Rheinhardt Message-Id: <65c941141655f8090e1ac91c71884dd135db8421.1750685809.git.ffmpegagent@gmail.com> In-Reply-To: References: Date: Mon, 23 Jun 2025 13:36:25 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 25/48] avcodec/mpegvideo: Move dct_precision to Mpeg4DecContext X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Andreas Rheinhardt Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg4videodec.c | 25 ++++++++++++++----------- libavcodec/mpeg4videodec.h | 1 + libavcodec/mpegvideo.h | 1 - 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 91b1687884..677b372fee 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -787,12 +787,13 @@ int ff_mpeg4_decode_video_packet_header(MPVContext *const s) return 0; } -static void reset_studio_dc_predictors(MpegEncContext *s) +static void reset_studio_dc_predictors(Mpeg4DecContext *const ctx) { + MPVContext *const s = &ctx->m; /* Reset DC Predictors */ s->last_dc[0] = s->last_dc[1] = - s->last_dc[2] = 1 << (s->avctx->bits_per_raw_sample + s->dct_precision + s->intra_dc_precision - 1); + s->last_dc[2] = 1 << (s->avctx->bits_per_raw_sample + ctx->dct_precision + s->intra_dc_precision - 1); } /** @@ -827,7 +828,7 @@ int ff_mpeg4_decode_studio_slice_header(MPVContext *const s) skip_bits(gb, 8); /* extra_information_slice */ } - reset_studio_dc_predictors(s); + reset_studio_dc_predictors(ctx); } else { return AVERROR_INVALIDDATA; @@ -2160,7 +2161,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n uint32_t flc; const int min = -1 * (1 << (s->avctx->bits_per_raw_sample + 6)); const int max = ((1 << (s->avctx->bits_per_raw_sample + 6)) - 1); - int shift = 3 - s->dct_precision; + int shift = 3 - ctx->dct_precision; mismatch = 1; @@ -2196,7 +2197,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n if (ctx->mpeg_quant) block[0] = s->last_dc[cc] * (8 >> s->intra_dc_precision); else - block[0] = s->last_dc[cc] * (8 >> s->intra_dc_precision) * (8 >> s->dct_precision); + block[0] = s->last_dc[cc] * (8 >> s->intra_dc_precision) * (8 >> ctx->dct_precision); /* TODO: support mpeg_quant for AC coefficients */ block[0] = av_clip(block[0], min, max); @@ -2246,7 +2247,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n if (idx > 63) return AVERROR_INVALIDDATA; j = scantable[idx++]; - additional_code_len = s->avctx->bits_per_raw_sample + s->dct_precision + 4; + additional_code_len = s->avctx->bits_per_raw_sample + ctx->dct_precision + 4; flc = get_bits(&s->gb, additional_code_len); if (flc >> (additional_code_len-1)) block[j] = -1 * (( flc ^ ((1 << additional_code_len) -1)) + 1); @@ -2263,8 +2264,10 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n return 0; } -static int mpeg4_decode_dpcm_macroblock(MpegEncContext *s, int16_t macroblock[256], int n) +static int mpeg4_decode_dpcm_macroblock(Mpeg4DecContext *const ctx, + int16_t macroblock[256], int n) { + MPVContext *const s = &ctx->m; int i, j, w, h, idx = 0; int block_mean, rice_parameter, rice_prefix_code, rice_suffix_code, dpcm_residual, left, top, topleft, min_left_top, max_left_top, p, p2, output; @@ -2276,7 +2279,7 @@ static int mpeg4_decode_dpcm_macroblock(MpegEncContext *s, int16_t macroblock[25 av_log(s->avctx, AV_LOG_ERROR, "Forbidden block_mean\n"); return AVERROR_INVALIDDATA; } - s->last_dc[n] = block_mean * (1 << (s->dct_precision + s->intra_dc_precision)); + s->last_dc[n] = block_mean * (1 << (ctx->dct_precision + s->intra_dc_precision)); rice_parameter = get_bits(&s->gb, 4); if (rice_parameter == 0) { @@ -2373,7 +2376,7 @@ static int mpeg4_decode_studio_mb(MpegEncContext *s, int16_t block_[12][64]) check_marker(s->avctx, &s->gb, "DPCM block start"); ctx->dpcm_direction = get_bits1(&s->gb) ? -1 : 1; for (i = 0; i < 3; i++) { - if (mpeg4_decode_dpcm_macroblock(s, ctx->dpcm_macroblock[i], i) < 0) + if (mpeg4_decode_dpcm_macroblock(ctx, ctx->dpcm_macroblock[i], i) < 0) return AVERROR_INVALIDDATA; } } @@ -3521,13 +3524,13 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) if (s->pict_type == AV_PICTURE_TYPE_I) { if (get_bits1(gb)) - reset_studio_dc_predictors(s); + reset_studio_dc_predictors(ctx); } if (ctx->shape != BIN_ONLY_SHAPE) { s->alternate_scan = get_bits1(gb); s->frame_pred_frame_dct = get_bits1(gb); - s->dct_precision = get_bits(gb, 2); + ctx->dct_precision = get_bits(gb, 2); s->intra_dc_precision = get_bits(gb, 2); s->q_scale_type = get_bits1(gb); } diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h index 32ad081df3..9598429d08 100644 --- a/libavcodec/mpeg4videodec.h +++ b/libavcodec/mpeg4videodec.h @@ -105,6 +105,7 @@ typedef struct Mpeg4DecContext { }; // 0 = DCT, 1 = DPCM top to bottom scan, -1 = DPCM bottom to top scan int dpcm_direction; + int dct_precision; } Mpeg4DecContext; int ff_mpeg4_decode_picture_header(MpegEncContext *s); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index d95cebedd8..81d2675f50 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -238,7 +238,6 @@ typedef struct MpegEncContext { /* MPEG-4 specific */ int studio_profile; - int dct_precision; int last_time_base; int time_base; ///< time in seconds of last I,P,S Frame int64_t time; ///< time of current frame -- ffmpeg-codebot _______________________________________________ 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".