[FFmpeg-devel] [PATCH v3 2/2] Newtek SpeedHQ decoder.

Michael Niedermayer michael at niedermayer.cc
Mon Jan 9 21:17:18 EET 2017


On Sun, Jan 08, 2017 at 12:07:09PM +0100, Steinar H. Gunderson wrote:
> This decoder can decode all existing SpeedHQ formats (SHQ0–5, 7, and 9),
> including correct decoding of the alpha channel.
> 
> 1080p is decoded in 142 fps on one core of my i7-4600U (2.1 GHz Haswell),
> about evenly split between bitstream reader and IDCT. There is currently
> no attempt at slice or frame threading, even though the format trivially
> supports both.
> 
> NewTek very helpfully provided a full set of SHQ samples, as well as
> source code for an SHQ2 encoder (not included) and assistance with
> understanding some details of the format.
> ---
[...]

> +static av_cold int speedhq_decode_init(AVCodecContext *avctx)
> +{
> +    static int done = 0;
> +    uint16_t ff_mpeg12_vlc_dc_lum_code_reversed[12];
> +    uint16_t ff_mpeg12_vlc_dc_chroma_code_reversed[12];
> +    SHQContext * const s = avctx->priv_data;
> +
> +    s->avctx = avctx;
> +
> +    if (!done) {
> +        int i;
> +
> +        /* Exactly the same as MPEG-2, except little-endian. */
> +        reverse_code(ff_mpeg12_vlc_dc_lum_code,
> +                     ff_mpeg12_vlc_dc_lum_bits,
> +                     ff_mpeg12_vlc_dc_lum_code_reversed,
> +                     12);
> +        INIT_LE_VLC_STATIC(&ff_dc_lum_vlc_le, DC_VLC_BITS, 12,
> +                           ff_mpeg12_vlc_dc_lum_bits, 1, 1,
> +                           ff_mpeg12_vlc_dc_lum_code_reversed, 2, 2, 512);
> +        reverse_code(ff_mpeg12_vlc_dc_chroma_code,
> +                     ff_mpeg12_vlc_dc_chroma_bits,
> +                     ff_mpeg12_vlc_dc_chroma_code_reversed,
> +                     12);
> +        INIT_LE_VLC_STATIC(&ff_dc_chroma_vlc_le, DC_VLC_BITS, 12,
> +                           ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
> +                           ff_mpeg12_vlc_dc_chroma_code_reversed, 2, 2, 514);
> +

> +        /* Reverse the AC VLC, because INIT_VLC_LE wants it in that order. */
> +        for (i = 0; i < FF_ARRAY_ELEMS(speedhq_vlc); ++i) {
> +            speedhq_vlc[i][0] = reverse(speedhq_vlc[i][0], speedhq_vlc[i][1]);
> +        }

This makes the init thread unsafe
it would be better if the table was const and this wasnt done at
runtime


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

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170109/66024373/attachment.sig>


More information about the ffmpeg-devel mailing list