From: Peter Ross <pross@xvid.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] lead: support format 0x0
Date: Thu, 15 Feb 2024 19:18:29 +1100
Message-ID: <Zc3I1Ziv9oXShfvd@869728a0df17329e597ee5994a1a1c9d> (raw)
In-Reply-To: <ffe58d4b38ed50f01100a283a564582ebe9cfb86.1699749638.git.pross@xvid.org>
[-- Attachment #1.1: Type: text/plain, Size: 4525 bytes --]
On Sun, Nov 12, 2023 at 11:41:23AM +1100, Peter Ross wrote:
> 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, AVFrame * frame,
> {
> LeadContext *s = avctx->priv_data;
> const uint8_t * buf = avpkt->data;
> - int ret, format, yuv20p_half = 0, fields = 1, q, size;
> + int ret, format, yuv420p_div = 1, yuv20p_half = 0, fields = 1, q, size;
> GetBitContext gb;
> int16_t dc_pred[3] = {0, 0, 0};
> uint16_t dequant[2][64];
> @@ -149,6 +149,10 @@ static int lead_decode_frame(AVCodecContext *avctx, AVFrame * frame,
>
> format = AV_RL16(buf + 4);
> switch(format) {
> + case 0x0:
> + yuv420p_div = 2;
> + avctx->pix_fmt = AV_PIX_FMT_YUV420P;
> + break;
> case 0x8000:
> yuv20p_half = 1;
> // fall-through
> @@ -192,29 +196,39 @@ static int lead_decode_frame(AVCodecContext *avctx, AVFrame * frame,
> init_get_bits8(&gb, s->bitstream_buf, size);
>
> if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) {
> - for (int mb_y = 0; mb_y < (avctx->height + 15) / 16; mb_y++)
> + for (int mb_y = 0; mb_y < (avctx->height + (16 / yuv420p_div - 1)) / (16 / yuv420p_div); mb_y++)
> for (int mb_x = 0; mb_x < (avctx->width + 15) / 16; mb_x++)
> - for (int b = 0; b < (yuv20p_half ? 4 : 6); b++) {
> - int luma_block = yuv20p_half ? 2 : 4;
> + for (int b = 0; b < ((yuv420p_div == 2 || yuv20p_half) ? 4 : 6); b++) {
> + int luma_block = (yuv420p_div == 2 || yuv20p_half) ? 2 : 4;
> const VLCElem * dc_vlc = b < luma_block ? luma_dc_vlc.table : chroma_dc_vlc.table;
> int dc_bits = b < luma_block ? LUMA_DC_BITS : CHROMA_DC_BITS;
> const VLCElem * ac_vlc = b < luma_block ? luma_ac_vlc.table : chroma_ac_vlc.table;
> int ac_bits = b < luma_block ? LUMA_AC_BITS : CHROMA_AC_BITS;
> - int plane = b < luma_block ? 0 : b - (yuv20p_half ? 1 : 3);
> - int x, y;
> + int plane = b < luma_block ? 0 : b - (luma_block - 1);
> + int x, y, yclip;
>
> if (b < luma_block) {
> - y = 16*mb_y + 8*(b >> 1);
> + y = (16 / yuv420p_div)*mb_y + 8*(b >> 1);
> x = 16*mb_x + 8*(b & 1);
> + yclip = 0;
> } else {
> - y = 8*mb_y;
> + y = (8 / yuv420p_div)*mb_y;
> x = 8*mb_x;
> + yclip = (yuv420p_div == 2) && y + 8 >= avctx->height / 2;
> }
>
> - ret = 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[plane]);
> + if (!yclip) {
> + ret = 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[plane]);
> + } else {
> + uint8_t tmp[64];
> + ret = decode_block(s, &gb, dc_vlc, dc_bits, ac_vlc, ac_bits,
> + dc_pred + plane, dequant[!(b < 4)], tmp, 8);
> + for (int yy = 0; yy < 8 && y + yy < avctx->height / 2; yy++)
> + memcpy(frame->data[plane] + (y+yy)*frame->linesize[plane] + x, tmp + yy, 8);
> + }
> if (ret < 0)
> return ret;
>
will apply in a few days.
-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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".
prev parent reply other threads:[~2024-02-15 8:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-12 0:41 Peter Ross
2024-02-15 8:18 ` Peter Ross [this message]
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=Zc3I1Ziv9oXShfvd@869728a0df17329e597ee5994a1a1c9d \
--to=pross@xvid.org \
--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