From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id E27B7481A0 for ; Sun, 12 Nov 2023 00:41:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E28A268CBFE; Sun, 12 Nov 2023 02:41:38 +0200 (EET) Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C302068CBA8 for ; Sun, 12 Nov 2023 02:41:32 +0200 (EET) Received: from b08755e23d758cbff113049ad395b92b ([1.152.210.249]) (authenticated (0 bits)) by mx.sdf.org (8.16.1/8.14.5) with ESMTPSA id 3AC0fRce027695 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for ; Sun, 12 Nov 2023 00:41:30 GMT Date: Sun, 12 Nov 2023 11:41:23 +1100 From: Peter Ross To: ffmpeg-devel@ffmpeg.org Message-ID: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lead: support format 0x0 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 Content-Type: multipart/mixed; boundary="===============4029552982949485495==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============4029552982949485495== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wde6UIVX1RgijDeD" Content-Disposition: inline --wde6UIVX1RgijDeD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Fixes ticket #10660. --- thanks to the mysterious 'ami_stuff'. libavcodec/leaddec.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/libavcodec/leaddec.c b/libavcodec/leaddec.c index fd2018256d..4f2cc03e65 100644 --- a/libavcodec/leaddec.c +++ b/libavcodec/leaddec.c @@ -139,7 +139,7 @@ static int lead_decode_frame(AVCodecContext *avctx, AVF= rame * frame, { LeadContext *s =3D avctx->priv_data; const uint8_t * buf =3D avpkt->data; - int ret, format, yuv20p_half =3D 0, fields =3D 1, q, size; + int ret, format, yuv420p_div =3D 1, yuv20p_half =3D 0, fields =3D 1, q= , size; GetBitContext gb; int16_t dc_pred[3] =3D {0, 0, 0}; uint16_t dequant[2][64]; @@ -149,6 +149,10 @@ static int lead_decode_frame(AVCodecContext *avctx, AV= Frame * frame, =20 format =3D AV_RL16(buf + 4); switch(format) { + case 0x0: + yuv420p_div =3D 2; + avctx->pix_fmt =3D AV_PIX_FMT_YUV420P; + break; case 0x8000: yuv20p_half =3D 1; // fall-through @@ -192,29 +196,39 @@ static int lead_decode_frame(AVCodecContext *avctx, A= VFrame * frame, init_get_bits8(&gb, s->bitstream_buf, size); =20 if (avctx->pix_fmt =3D=3D AV_PIX_FMT_YUV420P) { - for (int mb_y =3D 0; mb_y < (avctx->height + 15) / 16; mb_y++) + for (int mb_y =3D 0; mb_y < (avctx->height + (16 / yuv420p_div - 1= )) / (16 / yuv420p_div); mb_y++) for (int mb_x =3D 0; mb_x < (avctx->width + 15) / 16; mb_x++) - for (int b =3D 0; b < (yuv20p_half ? 4 : 6); b++) { - int luma_block =3D yuv20p_half ? 2 : 4; + for (int b =3D 0; b < ((yuv420p_div =3D=3D 2 || yuv20p_hal= f) ? 4 : 6); b++) { + int luma_block =3D (yuv420p_div =3D=3D 2 || yuv20p_hal= f) ? 2 : 4; const VLCElem * dc_vlc =3D b < luma_block ? luma_dc_vl= c.table : chroma_dc_vlc.table; int dc_bits =3D b < luma_block ? LUMA_DC_BI= TS : CHROMA_DC_BITS; const VLCElem * ac_vlc =3D b < luma_block ? luma_ac_vl= c.table : chroma_ac_vlc.table; int ac_bits =3D b < luma_block ? LUMA_AC_BI= TS : CHROMA_AC_BITS; - int plane =3D b < luma_block ? 0 : b - (y= uv20p_half ? 1 : 3); - int x, y; + int plane =3D b < luma_block ? 0 : b - (l= uma_block - 1); + int x, y, yclip; =20 if (b < luma_block) { - y =3D 16*mb_y + 8*(b >> 1); + y =3D (16 / yuv420p_div)*mb_y + 8*(b >> 1); x =3D 16*mb_x + 8*(b & 1); + yclip =3D 0; } else { - y =3D 8*mb_y; + y =3D (8 / yuv420p_div)*mb_y; x =3D 8*mb_x; + yclip =3D (yuv420p_div =3D=3D 2) && y + 8 >=3D avc= tx->height / 2; } =20 - ret =3D decode_block(s, &gb, dc_vlc, dc_bits, ac_vlc, = ac_bits, - dc_pred + plane, dequant[!(b < 4)], - frame->data[plane] + y*frame->linesize[plane] + x, - (yuv20p_half && b < 2 ? 2 : 1) * frame->linesize[p= lane]); + if (!yclip) { + ret =3D decode_block(s, &gb, dc_vlc, dc_bits, ac_v= lc, ac_bits, + dc_pred + plane, dequant[!(b < 4)], + frame->data[plane] + y*frame->linesize[plane] = + x, + (yuv20p_half && b < 2 ? 2 : 1) * frame->linesi= ze[plane]); + } else { + uint8_t tmp[64]; + ret =3D decode_block(s, &gb, dc_vlc, dc_bits, ac_v= lc, ac_bits, + dc_pred + plane, dequant[!(b < 4)], tmp, 8); + for (int yy =3D 0; yy < 8 && y + yy < avctx->heigh= t / 2; yy++) + memcpy(frame->data[plane] + (y+yy)*frame->line= size[plane] + x, tmp + yy, 8); + } if (ret < 0) return ret; =20 --=20 2.42.0 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) --wde6UIVX1RgijDeD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSpB+AvpuUM0jTNINJnYHnFrEDdawUCZVAfMwAKCRBnYHnFrEDd a3S3AJ4oJwtAf/zrGqsggOVlYfE/XAq/XgCgutCb5eBNn2MPZ+3YEOjq8TglWKA= =OEW4 -----END PGP SIGNATURE----- --wde6UIVX1RgijDeD-- --===============4029552982949485495== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============4029552982949485495==--