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 BCB474DB9E for ; Wed, 4 Jun 2025 05:39:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id CD2DB68BD5A; Wed, 4 Jun 2025 08:39:21 +0300 (EEST) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 26D3868B153 for ; Wed, 4 Jun 2025 08:39:15 +0300 (EEST) Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-22c336fcdaaso51336905ad.3 for ; Tue, 03 Jun 2025 22:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emma-gg.20230601.gappssmtp.com; s=20230601; t=1749015553; x=1749620353; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9p51x2d97NEgDnlt1z+SE2o4oKziBa7WQ0D5/REXgi0=; b=LLlN3jgbOILWsQRw9HGW5vQODzXmJUm1au8huKWzmJGnIBL6teBXaBOQQIsxyhGUoP VmqnYbC1+vh7lH9PfhD32xt+L0MwGoUbAmV83cvWQ8XymUsXFyfTCpPjtv4MSpnVreSt +eGLptQdwUB1IG6gSGSDzKGVQuYuX84byHPO7Zi7j8C/z8RipPb8nBTm1svafGApJG61 T4oZ9HaBQoE2ltwU+bfcryzmHI6/Ivg8e8ccRuff+OwQu61Tg9lNBjp3DcZGrp8ugwL8 A0VCC48A9jr0e3RVIOFlalD31SrLuG4Ds/J6kwgPbVcoq4Aqwpj4cmAeJCilJFrPas4Y whoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749015553; x=1749620353; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9p51x2d97NEgDnlt1z+SE2o4oKziBa7WQ0D5/REXgi0=; b=Hv2Tp0L0WyFMNcdCN08bmroHeuqa/jvsRVPTu/MaDFOykqxkwuvIReMWEJouj/9jEV DIO921J7+r9VoSCcLJcl6nOxwf/pWQtXKQ2F28Ea02QFYU1zOPUPvLlg941PFbVSLfJl J/akIwlaq9ldEJd6LPr9MAjRxCG7hM/o9txtFqN73IzR9KXaWzNjitxjeuSmB0Fp2okV GEtsLqcYRBpdaOCTTW/zQoSDE7BCY1CuhWX3UdPzAGQ/46xylM7Uy96jOxlyu7m/v6gz Wzt8os4DvouKNMJCy7+e6bGbzVMAM2YSISvfI85ZwMfpGFpw7qgvIou5OLuFnw8l9osC AGrQ== X-Gm-Message-State: AOJu0YyjazyacE5rs0q/xery9D++RnwsZnOrS0Y6+36qaAXbcEcLx+ze fIcU29m7pvd27iLnfbcOQkffg4FQuKPzg8/X5apZxch+raM0F5igyI5v5USWUTybsfuzRL6zh6x sAQF9 X-Gm-Gg: ASbGncuxNdbZzAPHwPjS7wkw0d0BHhIoYEQmicIX+SA8SatMNQDJfZNftZh2wbtERfC 7Id+9NXB41a15UpfMoYTWHKxbg5K9rJm7r4lWMS//sadGAjk/cuhRKWzQBRVqiv5PIeAn+WgFD3 OvD3ZeYSBZFsUassIThW3So1H1no/mXzlh29jtaCmd+nDUXaiLuXKkBEHwRVZSEclApP+e/SS3T BfI7ZRxwR5gPSI3B+WiLISWks6AJeaBkwY5sVmvtsEF6PP5JXZ1MVI32WicgWj9bNNuUj4sEe34 i5JK4mXa1DToWyFhNr1QnX8rUCXDqMTRL6dMnbpq4b2HUGrLkKSdznS3kw5VRklFra4lcm0= X-Google-Smtp-Source: AGHT+IHJHLfoivGo5skJMyOFSwF6e/jvK1k9EVZsoykS7XirQerFfrT+eeQcZLG0LCYjo8lP+g6POQ== X-Received: by 2002:a17:903:46c8:b0:234:d7b2:2ac4 with SMTP id d9443c01a7336-235e1126ed5mr22901565ad.17.1749015552607; Tue, 03 Jun 2025 22:39:12 -0700 (PDT) Received: from localhost ([2600:1700:65a7:3600:a818:4486:8a58:77fe]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-23506d14bcfsm96226675ad.236.2025.06.03.22.39.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Jun 2025 22:39:12 -0700 (PDT) From: Emma Worley To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 Jun 2025 22:38:21 -0700 Message-ID: <20250604053821.33129-1-emma@emma.gg> X-Mailer: git-send-email 2.48.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/dxvenc: fix big-endian issues in dxv_compress_dxt1 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: Emma Worley 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: We were using a mix of pointers to local variables read via AV_RL32/64 and pointers directly to the texture buffer as keys to interact with the lookback hashtables. On big-endian systems, these produced different values. This change makes all hashtable interactions use direct pointers to the texture buffer and only invokves AV_RL32 in the event of a lookback hashtable miss. Signed-off-by: Emma Worley --- libavcodec/dxvenc.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/libavcodec/dxvenc.c b/libavcodec/dxvenc.c index ee6a0a5b36..f5cef4f2e1 100644 --- a/libavcodec/dxvenc.c +++ b/libavcodec/dxvenc.c @@ -100,8 +100,7 @@ static int dxv_compress_dxt1(AVCodecContext *avctx) DXVEncContext *ctx = avctx->priv_data; PutByteContext *pbc = &ctx->pbc; void *value; - uint64_t combo; - uint32_t color, lut, idx, combo_idx, prev_pos, old_pos, state = 16, pos = 0, op = 0; + uint32_t idx, combo_idx, prev_pos, old_pos, state = 16, pos = 0, op = 0; ff_hashtable_clear(ctx->color_ht); ff_hashtable_clear(ctx->lut_ht); @@ -117,8 +116,7 @@ static int dxv_compress_dxt1(AVCodecContext *avctx) pos++; while (pos + 2 <= ctx->tex_size / 4) { - combo = AV_RL64(ctx->tex_data + pos * 4); - combo_idx = ff_hashtable_get(ctx->combo_ht, &combo, &prev_pos) ? pos - prev_pos : 0; + combo_idx = ff_hashtable_get(ctx->combo_ht, ctx->tex_data + pos * 4, &prev_pos) ? pos - prev_pos : 0; idx = combo_idx; PUSH_OP(2); if (pos >= LOOKBACK_WORDS) { @@ -126,36 +124,34 @@ static int dxv_compress_dxt1(AVCodecContext *avctx) if (ff_hashtable_get(ctx->combo_ht, ctx->tex_data + old_pos * 4, &prev_pos) && prev_pos <= old_pos) ff_hashtable_delete(ctx->combo_ht, ctx->tex_data + old_pos * 4); } - ff_hashtable_set(ctx->combo_ht, &combo, &pos); + ff_hashtable_set(ctx->combo_ht, ctx->tex_data + pos * 4, &pos); - color = AV_RL32(ctx->tex_data + pos * 4); if (!combo_idx) { - idx = ff_hashtable_get(ctx->color_ht, &color, &prev_pos) ? pos - prev_pos : 0; + idx = ff_hashtable_get(ctx->color_ht, ctx->tex_data + pos * 4, &prev_pos) ? pos - prev_pos : 0; PUSH_OP(2); if (!idx) - bytestream2_put_le32(pbc, color); + bytestream2_put_le32(pbc, AV_RL32(ctx->tex_data + pos * 4)); } if (pos >= LOOKBACK_WORDS) { old_pos = pos - LOOKBACK_WORDS; if (ff_hashtable_get(ctx->color_ht, ctx->tex_data + old_pos * 4, &prev_pos) && prev_pos <= old_pos) ff_hashtable_delete(ctx->color_ht, ctx->tex_data + old_pos * 4); } - ff_hashtable_set(ctx->color_ht, &color, &pos); + ff_hashtable_set(ctx->color_ht, ctx->tex_data + pos * 4, &pos); pos++; - lut = AV_RL32(ctx->tex_data + pos * 4); if (!combo_idx) { - idx = ff_hashtable_get(ctx->lut_ht, &lut, &prev_pos) ? pos - prev_pos : 0; + idx = ff_hashtable_get(ctx->lut_ht, ctx->tex_data + pos * 4, &prev_pos) ? pos - prev_pos : 0; PUSH_OP(2); if (!idx) - bytestream2_put_le32(pbc, lut); + bytestream2_put_le32(pbc, AV_RL32(ctx->tex_data + pos * 4)); } if (pos >= LOOKBACK_WORDS) { old_pos = pos - LOOKBACK_WORDS; if (ff_hashtable_get(ctx->lut_ht, ctx->tex_data + old_pos * 4, &prev_pos) && prev_pos <= old_pos) ff_hashtable_delete(ctx->lut_ht, ctx->tex_data + old_pos * 4); } - ff_hashtable_set(ctx->lut_ht, &lut, &pos); + ff_hashtable_set(ctx->lut_ht, ctx->tex_data + pos * 4, &pos); pos++; } -- 2.48.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".