From: Roy Funderburk <royffmpeg@funderburk.us>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] avformat/avcodec: Add DTS-UHD demuxer and parser, movenc support.
Date: Thu, 15 Jun 2023 11:44:42 -0700
Message-ID: <f7bd020c-c5ab-c3d6-1ead-9abfd1b85888@funderburk.us> (raw)
In-Reply-To: <CAPYw7P6gwxrRNre2BkrrMQf1_qnc=aooeGvO45NFJpZ2YAs2kg@mail.gmail.com>
On 6/15/23 8:46 AM, Paul B Mahol wrote:
> get_vlc2 can be made for get_bits_var(), first table bits (that are still
> int and not uint8_t), the code that picks table index from which to take
> bits.
>
> It is also possible to make it take both first index and rest of it and
> build bigger tables but that is very very advanced step for new
> contributors.
>
> Use INIT_VLC_SPARSE_STATIC, there are myriad examples in libavcodec, one of
> them being imm4 decoder.
>
I will change that table bits array to uint8_t.
I encountered an issue when trying to set up the VLC table with
INIT_VLC_SPARSE_STATIC.
The current get_bits_var:
static int get_bits_var(GetBitContext *gb, const VarBits *var_bits)
{
static const uint8_t bits_used[8] = { 1, 1, 1, 1, 2, 2, 3, 3 };
int code = show_bits(gb, 3); /* value range is [0, 7] */
skip_bits(gb, bits_used[code]);
if (var_bits->bits[code] == 0)
return 0;
return get_bits_long(gb, var_bits->bits[code]) + var_bits->add[code];
}
Changed to use get_vlc2 would be:
static int get_bits_var(GetBitContext *gb, const VarBits *var_bits)
{
int code = get_vlc2(&gb, vlc.table, 3, 1);
if (var_bits->bits[code] == 0)
return 0;
return get_bits_long(gb, var_bits->bits[code]) + var_bits->add[code];
}
The "vlc.table" that INIT_VLC_SPARSE_STATIC needs to output is:
len: 1, 1, 1, 1, 2, 2, 3, 3
sym: 4, 4, 4, 4, 8, 8, 16, 32
INIT_VLC_SPARSE_STATIC would get the same len and sym and this code table as input:
code: 0, 1, 2, 3, 4, 5, 6, 7
INIT_VLC_SPARSE_STATIC rejects the "len" and "code" because the code
of "2" will not fit into one bit. Regardless of the fact that the desired
output table is not a valid table according to VLC functions, that invalid
table is what is needed.
This goes back to how get_bits_var decodes the bit context.
get_bits_var looks at three bits to get an index in the range of 0-7.
But it may not skip all of those bits. One or two of those bits may also be
read by the final get_bits_long.
code = show_bits(gb, 3);
skip_bits(gb, bits_used[code]);
get_bits_long(gb,...);
The VLC functions to construct tables have validation in place that prevents
the construction of the table needed for get_vlc2() to work with
get_bits_var.
So the only way I can find to use get_vlc2() is to not use any of the vlc.h
initialization functions, and instead hard-code the tables to be used by
get_vlc2() like this:
VLCElem table[8] = { {4,1}, {4,1}, {4,1}, {4,1}, {8,2}, {8,2}, {16,3}, {32,3} };
Before I do that, I wanted to verify this would be acceptable. Would
this be a use of get_vlc2() that could lead to issues in the future
if the GET_VLC macro changed so that it would not skip fewer bits than the
code length?
What is your opinion on this?
Thanks,
-Roy
_______________________________________________
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-06-15 18:44 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-14 15:39 Roy Funderburk
2023-04-14 16:40 ` Hendrik Leppkes
2023-04-14 16:48 ` Roy Funderburk
2023-04-15 14:56 ` Michael Niedermayer
2023-04-15 20:04 ` [FFmpeg-devel] [PATCH v2] " Roy Funderburk
2023-04-16 19:55 ` Michael Niedermayer
2023-04-16 21:52 ` Roy Funderburk
2023-04-17 4:12 ` [FFmpeg-devel] [PATCH v3 1/2] " Roy Funderburk
2023-05-08 17:49 ` Roy Funderburk
2023-05-13 7:28 ` Paul B Mahol
2023-05-15 14:50 ` Roy Funderburk
2023-05-15 20:35 ` Michael Niedermayer
2023-05-15 21:14 ` Roy Funderburk
2023-06-13 14:26 ` Paul B Mahol
2023-06-13 17:43 ` Roy Funderburk
2023-06-13 18:09 ` Paul B Mahol
2023-06-13 18:20 ` Roy Funderburk
2023-06-13 19:04 ` Anton Khirnov
2023-04-17 4:13 ` [FFmpeg-devel] [PATCH v3 2/2] " Roy Funderburk
2023-06-13 18:32 ` Paul B Mahol
2023-04-15 20:20 ` [FFmpeg-devel] [PATCH] " Roy Funderburk
2023-06-13 18:35 ` Paul B Mahol
2023-06-14 0:00 ` Roy Funderburk
2023-06-14 5:37 ` Paul B Mahol
2023-06-14 6:01 ` Paul B Mahol
2023-06-14 6:06 ` Paul B Mahol
2023-06-14 6:11 ` Paul B Mahol
2023-06-14 18:24 ` Roy Funderburk
2023-06-14 20:01 ` Roy Funderburk
2023-06-15 15:46 ` Paul B Mahol
2023-06-15 18:44 ` Roy Funderburk [this message]
2023-06-18 12:18 ` Paul B Mahol
2023-06-20 17:05 ` Roy Funderburk
2023-08-17 21:47 ` Roy Funderburk
2023-08-17 22:31 ` Paul B Mahol
2023-08-17 22:51 ` Roy Funderburk
2024-01-16 21:02 ` Roy Funderburk
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=f7bd020c-c5ab-c3d6-1ead-9abfd1b85888@funderburk.us \
--to=royffmpeg@funderburk.us \
--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