1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec: Replace get_bits_long() by get_bits() where possible

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2019-11-24 15:31:14 +01:00
parent 9a8471e3f0
commit a15d904ad7
15 changed files with 23 additions and 23 deletions

View File

@ -493,7 +493,7 @@ int ff_bgmc_decode_init(GetBitContext *gb, unsigned int *h,
*h = TOP_VALUE; *h = TOP_VALUE;
*l = 0; *l = 0;
*v = get_bits_long(gb, VALUE_BITS); *v = get_bits(gb, VALUE_BITS);
return 0; return 0;
} }

View File

@ -153,7 +153,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
static float get_float(GetBitContext *gb) static float get_float(GetBitContext *gb)
{ {
int power = get_bits(gb, 5); int power = get_bits(gb, 5);
float f = ldexpf(get_bits_long(gb, 23), power - 23); float f = ldexpf(get_bits(gb, 23), power - 23);
if (get_bits1(gb)) if (get_bits1(gb))
f = -f; f = -f;
return f; return f;

View File

@ -252,7 +252,7 @@ static int escape124_decode_frame(AVCodecContext *avctx,
if (i == 2) { if (i == 2) {
// This codebook can be cut off at places other than // This codebook can be cut off at places other than
// powers of 2, leaving some of the entries undefined. // powers of 2, leaving some of the entries undefined.
cb_size = get_bits_long(&gb, 20); cb_size = get_bits(&gb, 20);
if (!cb_size) { if (!cb_size) {
av_log(avctx, AV_LOG_ERROR, "Invalid codebook size 0.\n"); av_log(avctx, AV_LOG_ERROR, "Invalid codebook size 0.\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;

View File

@ -217,9 +217,9 @@ int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
} }
skip_bits(&gb, 24); /* skip min frame size */ skip_bits(&gb, 24); /* skip min frame size */
s->max_framesize = get_bits_long(&gb, 24); s->max_framesize = get_bits(&gb, 24);
s->samplerate = get_bits_long(&gb, 20); s->samplerate = get_bits(&gb, 20);
s->channels = get_bits(&gb, 3) + 1; s->channels = get_bits(&gb, 3) + 1;
s->bps = get_bits(&gb, 5) + 1; s->bps = get_bits(&gb, 5) + 1;

View File

@ -30,7 +30,7 @@ int ff_flv_decode_picture_header(MpegEncContext *s)
int format, width, height; int format, width, height;
/* picture header */ /* picture header */
if (get_bits_long(&s->gb, 17) != 1) { if (get_bits(&s->gb, 17) != 1) {
av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }

View File

@ -76,8 +76,8 @@ static int decode_nal_sei_mastering_display_info(HEVCSEIMasteringDisplay *s, Get
static int decode_nal_sei_content_light_info(HEVCSEIContentLight *s, GetBitContext *gb) static int decode_nal_sei_content_light_info(HEVCSEIContentLight *s, GetBitContext *gb)
{ {
// Max and average light levels // Max and average light levels
s->max_content_light_level = get_bits_long(gb, 16); s->max_content_light_level = get_bits(gb, 16);
s->max_pic_average_light_level = get_bits_long(gb, 16); s->max_pic_average_light_level = get_bits(gb, 16);
// As this SEI message comes before the first frame that references it, // As this SEI message comes before the first frame that references it,
// initialize the flag to 2 and decrement on IRAP access unit so it // initialize the flag to 2 and decrement on IRAP access unit so it
// persists for the coded video sequence (e.g., between two IRAPs) // persists for the coded video sequence (e.g., between two IRAPs)

View File

@ -348,7 +348,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
if (ctx->frame_type != FRAMETYPE_NULL) { if (ctx->frame_type != FRAMETYPE_NULL) {
ctx->frame_flags = get_bits(&ctx->gb, 8); ctx->frame_flags = get_bits(&ctx->gb, 8);
ctx->pic_hdr_size = (ctx->frame_flags & 1) ? get_bits_long(&ctx->gb, 24) : 0; ctx->pic_hdr_size = (ctx->frame_flags & 1) ? get_bits(&ctx->gb, 24) : 0;
ctx->checksum = (ctx->frame_flags & 0x10) ? get_bits(&ctx->gb, 16) : 0; ctx->checksum = (ctx->frame_flags & 0x10) ? get_bits(&ctx->gb, 16) : 0;
@ -392,7 +392,7 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
return 0; return 0;
} }
band->data_size = (ctx->frame_flags & 0x80) ? get_bits_long(&ctx->gb, 24) : 0; band->data_size = (ctx->frame_flags & 0x80) ? get_bits(&ctx->gb, 24) : 0;
band->inherit_mv = band_flags & 2; band->inherit_mv = band_flags & 2;
band->inherit_qdelta = band_flags & 8; band->inherit_qdelta = band_flags & 8;

View File

@ -33,7 +33,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
} }
/* picture header */ /* picture header */
if (get_bits_long(&s->gb, 22) != 0x20) { if (get_bits(&s->gb, 22) != 0x20) {
av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
return -1; return -1;
} }

View File

@ -476,7 +476,7 @@ static int ivi_dec_tile_data_size(GetBitContext *gb)
if (get_bits1(gb)) { if (get_bits1(gb)) {
len = get_bits(gb, 8); len = get_bits(gb, 8);
if (len == 255) if (len == 255)
len = get_bits_long(gb, 24); len = get_bits(gb, 24);
} }
/* align the bitstream reader on the byte boundary */ /* align the bitstream reader on the byte boundary */

View File

@ -2049,7 +2049,7 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
unsigned nummarkers; unsigned nummarkers;
id = get_bits_long(&s->gb, 32); id = get_bits_long(&s->gb, 32);
id2 = get_bits_long(&s->gb, 24); id2 = get_bits(&s->gb, 24);
len -= 7; len -= 7;
if (id != AV_RB32("PROF") || id2 != AV_RB24("ILE")) { if (id != AV_RB32("PROF") || id2 != AV_RB24("ILE")) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid ICC_PROFILE header in APP2\n"); av_log(s->avctx, AV_LOG_WARNING, "Invalid ICC_PROFILE header in APP2\n");

View File

@ -102,7 +102,7 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (get_bits_long(gb, 24) != 0xf8726f) /* Sync words */ if (get_bits(gb, 24) != 0xf8726f) /* Sync words */
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
mh->stream_type = get_bits(gb, 8); mh->stream_type = get_bits(gb, 8);

View File

@ -1001,7 +1001,7 @@ int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx)
if (s->pict_type == AV_PICTURE_TYPE_I) { if (s->pict_type == AV_PICTURE_TYPE_I) {
while (show_bits(&s->gb, 9) == 1) while (show_bits(&s->gb, 9) == 1)
skip_bits(&s->gb, 9); skip_bits(&s->gb, 9);
if (get_bits_long(&s->gb, 19) != DC_MARKER) { if (get_bits(&s->gb, 19) != DC_MARKER) {
av_log(s->avctx, AV_LOG_ERROR, av_log(s->avctx, AV_LOG_ERROR,
"marker missing after first I partition at %d %d\n", "marker missing after first I partition at %d %d\n",
s->mb_x, s->mb_y); s->mb_x, s->mb_y);

View File

@ -155,7 +155,7 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
huff.val_bits = get_bits(&ctx->gb, 5); huff.val_bits = get_bits(&ctx->gb, 5);
huff.max_bits = get_bits(&ctx->gb, 5); huff.max_bits = get_bits(&ctx->gb, 5);
huff.min_bits = get_bits(&ctx->gb, 5); huff.min_bits = get_bits(&ctx->gb, 5);
huff.nodes = get_bits_long(&ctx->gb, 17); huff.nodes = get_bits(&ctx->gb, 17);
huff.num = 0; huff.num = 0;
/* check for correct codes parameters */ /* check for correct codes parameters */

View File

@ -2967,7 +2967,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
AVRational fps, aspect; AVRational fps, aspect;
s->theora_header = 0; s->theora_header = 0;
s->theora = get_bits_long(gb, 24); s->theora = get_bits(gb, 24);
av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora); av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora);
if (!s->theora) { if (!s->theora) {
s->theora = 1; s->theora = 1;
@ -2988,8 +2988,8 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
s->height = get_bits(gb, 16) << 4; s->height = get_bits(gb, 16) << 4;
if (s->theora >= 0x030200) { if (s->theora >= 0x030200) {
visible_width = get_bits_long(gb, 24); visible_width = get_bits(gb, 24);
visible_height = get_bits_long(gb, 24); visible_height = get_bits(gb, 24);
offset_x = get_bits(gb, 8); /* offset x */ offset_x = get_bits(gb, 8); /* offset x */
offset_y = get_bits(gb, 8); /* offset y, from bottom */ offset_y = get_bits(gb, 8); /* offset y, from bottom */
@ -3017,8 +3017,8 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
fps.den, fps.num, 1 << 30); fps.den, fps.num, 1 << 30);
} }
aspect.num = get_bits_long(gb, 24); aspect.num = get_bits(gb, 24);
aspect.den = get_bits_long(gb, 24); aspect.den = get_bits(gb, 24);
if (aspect.num && aspect.den) { if (aspect.num && aspect.den) {
av_reduce(&avctx->sample_aspect_ratio.num, av_reduce(&avctx->sample_aspect_ratio.num,
&avctx->sample_aspect_ratio.den, &avctx->sample_aspect_ratio.den,

View File

@ -514,7 +514,7 @@ static int decode_frame_header(AVCodecContext *avctx,
s->s.h.use_last_frame_mvs = !s->s.h.errorres && !last_invisible; s->s.h.use_last_frame_mvs = !s->s.h.errorres && !last_invisible;
if (s->s.h.keyframe) { if (s->s.h.keyframe) {
if (get_bits_long(&s->gb, 24) != VP9_SYNCCODE) { // synccode if (get_bits(&s->gb, 24) != VP9_SYNCCODE) { // synccode
av_log(avctx, AV_LOG_ERROR, "Invalid sync code\n"); av_log(avctx, AV_LOG_ERROR, "Invalid sync code\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
@ -530,7 +530,7 @@ static int decode_frame_header(AVCodecContext *avctx,
s->s.h.intraonly = s->s.h.invisible ? get_bits1(&s->gb) : 0; s->s.h.intraonly = s->s.h.invisible ? get_bits1(&s->gb) : 0;
s->s.h.resetctx = s->s.h.errorres ? 0 : get_bits(&s->gb, 2); s->s.h.resetctx = s->s.h.errorres ? 0 : get_bits(&s->gb, 2);
if (s->s.h.intraonly) { if (s->s.h.intraonly) {
if (get_bits_long(&s->gb, 24) != VP9_SYNCCODE) { // synccode if (get_bits(&s->gb, 24) != VP9_SYNCCODE) { // synccode
av_log(avctx, AV_LOG_ERROR, "Invalid sync code\n"); av_log(avctx, AV_LOG_ERROR, "Invalid sync code\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }