2007-08-27 01:33:48 +03:00
|
|
|
/*
|
|
|
|
* copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* This file is part of Libav.
|
2007-08-27 01:33:48 +03:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2007-08-27 01:33:48 +03:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2007-08-27 01:33:48 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2011-03-18 19:35:10 +02:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2007-08-27 01:33:48 +03:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2008-08-31 10:39:47 +03:00
|
|
|
#ifndef AVCODEC_UNARY_H
|
|
|
|
#define AVCODEC_UNARY_H
|
2007-08-27 01:33:48 +03:00
|
|
|
|
2016-06-08 11:31:33 +02:00
|
|
|
#include "bitstream.h"
|
2007-08-27 01:33:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get unary code of limited length
|
2016-06-08 11:31:33 +02:00
|
|
|
* @param bc BitstreamContext
|
2007-08-27 01:33:48 +03:00
|
|
|
* @param[in] stop The bitstop value (unary code of 1's or 0's)
|
|
|
|
* @param[in] len Maximum length
|
|
|
|
* @return Unary length/index
|
|
|
|
*/
|
2016-06-08 11:31:33 +02:00
|
|
|
static inline int get_unary(BitstreamContext *bc, int stop, int len)
|
2007-08-27 01:33:48 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2016-06-08 11:31:33 +02:00
|
|
|
for (i = 0; i < len && bitstream_read_bit(bc) != stop; i++)
|
|
|
|
;
|
2007-08-27 01:33:48 +03:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2007-08-27 01:38:57 +03:00
|
|
|
/**
|
|
|
|
* Get unary code terminated by a 0 with a maximum length of 33
|
2016-06-08 11:31:33 +02:00
|
|
|
* @param bc BitstreamContext
|
2007-08-27 01:38:57 +03:00
|
|
|
* @return Unary length/index
|
|
|
|
*/
|
2016-06-08 11:31:33 +02:00
|
|
|
static inline int get_unary_0_33(BitstreamContext *bc)
|
2007-08-27 01:38:57 +03:00
|
|
|
{
|
2016-06-08 11:31:33 +02:00
|
|
|
return get_unary(bc, 0, 33);
|
2007-08-27 01:38:57 +03:00
|
|
|
}
|
|
|
|
|
2016-06-08 11:31:33 +02:00
|
|
|
static inline int get_unary_0_9(BitstreamContext *bc)
|
2007-09-02 00:03:17 +03:00
|
|
|
{
|
2016-06-08 11:31:33 +02:00
|
|
|
return get_unary(bc, 0, 9);
|
2007-09-02 00:03:17 +03:00
|
|
|
}
|
|
|
|
|
2008-08-31 10:39:47 +03:00
|
|
|
#endif /* AVCODEC_UNARY_H */
|