[FFmpeg-devel] [PATCH 6/7] lavc: add a ProRes RAW decoder

Michael Niedermayer michael at niedermayer.cc
Sat Jul 12 14:50:45 EEST 2025


Hi Lynne

On Fri, Jul 11, 2025 at 12:13:34AM +0900, Lynne wrote:
> ---
>  configure                  |   1 +
>  libavcodec/Makefile        |   1 +
>  libavcodec/allcodecs.c     |   1 +
>  libavcodec/proresdec_raw.c | 519 +++++++++++++++++++++++++++++++++++++
>  libavcodec/proresdec_raw.h |  60 +++++
>  5 files changed, 582 insertions(+)
>  create mode 100644 libavcodec/proresdec_raw.c
>  create mode 100644 libavcodec/proresdec_raw.h
[...]

> +static int16_t get_value(GetBitContext *gb, int16_t codebook)
> +{
> +    const int16_t switch_bits = codebook >> 8;
> +    const int16_t rice_order  = codebook & 0xf;
> +    const int16_t exp_order   = (codebook >> 4) & 0xf;
> +    int16_t q, bits;
> +
> +    uint32_t b = show_bits_long(gb, 32);
> +    if (!b)
> +        return 0;
> +    q = ff_clz(b);
> +
> +    if (b & 0x80000000) {
> +        skip_bits_long(gb, 1 + rice_order);
> +        return (b & 0x7FFFFFFF) >> (31 - rice_order);
> +    }
> +
> +    if (q <= switch_bits) {
> +        skip_bits_long(gb, 1 + rice_order + q);
> +        return (q << rice_order) +
> +                (((b << (q + 1)) >> 1) >> (31 - rice_order));
> +    }
> +
> +    bits = exp_order + (q << 1) - switch_bits;
> +    skip_bits_long(gb, bits);
> +    return (b >> (32 - bits)) +
> +           ((switch_bits + 1) << rice_order) -
> +           (1 << exp_order);
> +}
> +

> +#define TODCCODEBOOK(x) (((x) & 1) + (x) >> 1)

(x) + 1 >> 1


> +
> +static const uint8_t align_tile_w[16] = {
> +    0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
> +};
> +

> +const int16_t ff_prores_raw_dc_cb[13] = {
> +    16, 33, 50, 51, 51, 51, 68, 68, 68, 68, 68, 68, 118,
> +};

int8_t

[...]
> +    /* Special handling for first block */
> +    dc = get_value(&gb, 700);

> +    prev_dc = ((dc & 1) + (dc >> 1) ^ -(int)(dc & 1)) + (dc & 1);

    prev_dc = (dc >> 1) ^ -(dc & 1);


thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250712/70bb3560/attachment.sig>


More information about the ffmpeg-devel mailing list