History

avcodec/proresdec: Don't use LONG_BITSTREAM_READER

Using LONG_BITSTREAM_READER means that every get_bits() call uses an AV_RB64() to ensure that cache always contains 32 valid bits (as opposed to the ordinary 25 guaranteed by reading 32 bits); yet this is unnecessary when unpacking alpha. So only use these 64bit reads where necessary.

Andreas Rheinhardt committed 1 year ago

Commit 8ad2dae1 parent ee1408c1 file · +3 −5Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/proresdec.c+3−5
@@ -26,8 +26,6 @@ · 25 unmodified lines
26 26
27//#define DEBUG27//#define DEBUG
28 28
29#define LONG_BITSTREAM_READER
30
31#include "config_components.h"29#include "config_components.h"
32 30
33#include "libavutil/internal.h"31#include "libavutil/internal.h"
@@ -428,7 +426,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons · 394 unmodified lines
428 unsigned int rice_order, exp_order, switch_bits; \426 unsigned int rice_order, exp_order, switch_bits; \
429 unsigned int q, buf, bits; \427 unsigned int q, buf, bits; \
430 \428 \
431 UPDATE_CACHE(re, gb); \429 UPDATE_CACHE_32(re, gb); /* We really need 32 bits */ \
432 buf = GET_CACHE(re, gb); \430 buf = GET_CACHE(re, gb); \
433 \431 \
434 /* number of bits to switch between rice and exp golomb */ \432 /* number of bits to switch between rice and exp golomb */ \
@@ -440,7 +438,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons · 5 unmodified lines
440 \438 \
441 if (q > switch_bits) { /* exp golomb */ \439 if (q > switch_bits) { /* exp golomb */ \
442 bits = exp_order - switch_bits + (q<<1); \440 bits = exp_order - switch_bits + (q<<1); \
443 if (bits > FFMIN(MIN_CACHE_BITS, 31)) \441 if (bits > 31) \
444 return AVERROR_INVALIDDATA; \442 return AVERROR_INVALIDDATA; \
445 val = SHOW_UBITS(re, gb, bits) - (1 << exp_order) + \443 val = SHOW_UBITS(re, gb, bits) - (1 << exp_order) + \
446 ((switch_bits + 1) << rice_order); \444 ((switch_bits + 1) << rice_order); \
@@ -502,7 +500,7 @@ static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContex · 55 unmodified lines
502 int log2_block_count = av_log2(blocks_per_slice);500 int log2_block_count = av_log2(blocks_per_slice);
503 501
504 OPEN_READER(re, gb);502 OPEN_READER(re, gb);
505 UPDATE_CACHE(re, gb); \503 UPDATE_CACHE_32(re, gb);
506 run = 4;504 run = 4;
507 level = 2;505 level = 2;
508 506

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t