[FFmpeg-devel] [PATCH 2/2] avcodec/huffyuvdec: optimize decode_plane_bitstream(), use joint tables for new yuv formats
Michael Niedermayer
michaelni at gmx.at
Mon Jan 6 02:38:11 CET 2014
On Fri, Jan 03, 2014 at 03:32:21PM +0100, Paul B Mahol wrote:
> On 1/1/14, Michael Niedermayer <michaelni at gmx.at> wrote:
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> > libavcodec/huffyuvdec.c | 23 ++++++++++++++++-------
> > 1 file changed, 16 insertions(+), 7 deletions(-)
> >
> > diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
> > index 11c87bd..b88e683 100644
> > --- a/libavcodec/huffyuvdec.c
> > +++ b/libavcodec/huffyuvdec.c
> > @@ -114,11 +114,12 @@ static int generate_joint_tables(HYuvContext *s)
> > uint8_t len[1 << VLC_BITS];
> > int ret;
> >
> > - if (s->bitstream_bpp < 24) {
> > + if (s->bitstream_bpp < 24 || s->version > 2) {
> > int p, i, y, u;
> > for (p = 0; p < 3; p++) {
> > + int p0 = s->version > 2 ? p : 0;
> > for (i = y = 0; y < 256; y++) {
> > - int len0 = s->len[0][y];
> > + int len0 = s->len[p0][y];
> > int limit = VLC_BITS - len0;
> > if(limit <= 0 || !len0)
> > continue;
> > @@ -128,7 +129,7 @@ static int generate_joint_tables(HYuvContext *s)
> > continue;
> > av_assert0(i < (1 << VLC_BITS));
> > len[i] = len0 + len1;
> > - bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
> > + bits[i] = (s->bits[p0][y] << len1) + s->bits[p][u];
> > symbols[i] = (y << 8) + u;
> > if(symbols[i] != 0xffff) // reserved to mean "invalid"
> > i++;
> > @@ -461,6 +462,16 @@ static void decode_422_bitstream(HYuvContext *s, int
> > count)
> > }
> > }
> >
> > +#define READ_2PIX_PLANE(dst0, dst1, plane){\
> > + uint16_t code = get_vlc2(&s->gb, s->vlc[3+plane].table, VLC_BITS, 1);\
> > + if(code != 0xffff){\
> > + dst0 = code>>8;\
> > + dst1 = code;\
> > + }else{\
> > + dst0 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3);\
> > + dst1 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3);\
> > + }\
> > +}
> > static void decode_plane_bitstream(HYuvContext *s, int count, int plane)
> > {
> > int i;
> > @@ -469,13 +480,11 @@ static void decode_plane_bitstream(HYuvContext *s, int
> > count, int plane)
> >
> > if (count >= (get_bits_left(&s->gb)) / (31 * 2)) {
> > for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
> > - s->temp[0][2*i ] = get_vlc2(&s->gb, s->vlc[plane].table,
> > VLC_BITS, 3);
> > - s->temp[0][2*i + 1] = get_vlc2(&s->gb, s->vlc[plane].table,
> > VLC_BITS, 3);
> > + READ_2PIX_PLANE(s->temp[0][2 * i], s->temp[0][2 * i + 1],
> > plane);
> > }
> > } else {
> > for(i=0; i<count; i++){
> > - s->temp[0][2*i ] = get_vlc2(&s->gb, s->vlc[plane].table,
> > VLC_BITS, 3);
> > - s->temp[0][2*i + 1] = get_vlc2(&s->gb, s->vlc[plane].table,
> > VLC_BITS, 3);
> > + READ_2PIX_PLANE(s->temp[0][2 * i], s->temp[0][2 * i + 1],
> > plane);
> > }
> > }
> > }
> > --
> > 1.7.9.5
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
>
> probably ok
applied
thanks
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140106/aa2dd0e3/attachment.asc>
More information about the ffmpeg-devel
mailing list