Skip to content

Commit

Permalink
Merge commit '4024b566d664a4b161d677554be52f32e7ad4236'
Browse files Browse the repository at this point in the history
* commit '4024b566d664a4b161d677554be52f32e7ad4236':
  golomb: Give svq3_get_se_golomb()/svq3_get_ue_golomb() better names

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
  • Loading branch information
Nevcairiel committed Jun 26, 2016
2 parents 324f0fb + 4024b56 commit b20fe65
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 87 deletions.
58 changes: 29 additions & 29 deletions libavcodec/dirac.c
Expand Up @@ -151,16 +151,16 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb,
/* [DIRAC_STD] 10.3.2 Frame size. frame_size(video_params) */
/* [DIRAC_STD] custom_dimensions_flag */
if (get_bits1(gb)) {
dsh->width = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_WIDTH */
dsh->height = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_HEIGHT */
dsh->width = get_interleaved_ue_golomb(gb); /* [DIRAC_STD] FRAME_WIDTH */
dsh->height = get_interleaved_ue_golomb(gb); /* [DIRAC_STD] FRAME_HEIGHT */
}

/* [DIRAC_STD] 10.3.3 Chroma Sampling Format.
* chroma_sampling_format(video_params) */
/* [DIRAC_STD] custom_chroma_format_flag */
if (get_bits1(gb))
/* [DIRAC_STD] CHROMA_FORMAT_INDEX */
dsh->chroma_format = svq3_get_ue_golomb(gb);
dsh->chroma_format = get_interleaved_ue_golomb(gb);
if (dsh->chroma_format > 2U) {
if (log_ctx)
av_log(log_ctx, AV_LOG_ERROR, "Unknown chroma format %d\n",
Expand All @@ -172,22 +172,22 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb,
/* [DIRAC_STD] custom_scan_format_flag */
if (get_bits1(gb))
/* [DIRAC_STD] SOURCE_SAMPLING */
dsh->interlaced = svq3_get_ue_golomb(gb);
dsh->interlaced = get_interleaved_ue_golomb(gb);
if (dsh->interlaced > 1U)
return AVERROR_INVALIDDATA;

/* [DIRAC_STD] 10.3.5 Frame Rate. frame_rate(video_params) */
if (get_bits1(gb)) { /* [DIRAC_STD] custom_frame_rate_flag */
dsh->frame_rate_index = svq3_get_ue_golomb(gb);
dsh->frame_rate_index = get_interleaved_ue_golomb(gb);

if (dsh->frame_rate_index > 10U)
return AVERROR_INVALIDDATA;

if (!dsh->frame_rate_index) {
/* [DIRAC_STD] FRAME_RATE_NUMER */
frame_rate.num = svq3_get_ue_golomb(gb);
frame_rate.num = get_interleaved_ue_golomb(gb);
/* [DIRAC_STD] FRAME_RATE_DENOM */
frame_rate.den = svq3_get_ue_golomb(gb);
frame_rate.den = get_interleaved_ue_golomb(gb);
}
}
/* [DIRAC_STD] preset_frame_rate(video_params, index) */
Expand All @@ -204,14 +204,14 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb,
* pixel_aspect_ratio(video_params) */
if (get_bits1(gb)) { /* [DIRAC_STD] custom_pixel_aspect_ratio_flag */
/* [DIRAC_STD] index */
dsh->aspect_ratio_index = svq3_get_ue_golomb(gb);
dsh->aspect_ratio_index = get_interleaved_ue_golomb(gb);

if (dsh->aspect_ratio_index > 6U)
return AVERROR_INVALIDDATA;

if (!dsh->aspect_ratio_index) {
dsh->sample_aspect_ratio.num = svq3_get_ue_golomb(gb);
dsh->sample_aspect_ratio.den = svq3_get_ue_golomb(gb);
dsh->sample_aspect_ratio.num = get_interleaved_ue_golomb(gb);
dsh->sample_aspect_ratio.den = get_interleaved_ue_golomb(gb);
}
}
/* [DIRAC_STD] Take value from Table 10.4 Available preset pixel
Expand All @@ -223,31 +223,31 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb,
/* [DIRAC_STD] 10.3.7 Clean area. clean_area(video_params) */
if (get_bits1(gb)) { /* [DIRAC_STD] custom_clean_area_flag */
/* [DIRAC_STD] CLEAN_WIDTH */
dsh->clean_width = svq3_get_ue_golomb(gb);
dsh->clean_width = get_interleaved_ue_golomb(gb);
/* [DIRAC_STD] CLEAN_HEIGHT */
dsh->clean_height = svq3_get_ue_golomb(gb);
dsh->clean_height = get_interleaved_ue_golomb(gb);
/* [DIRAC_STD] CLEAN_LEFT_OFFSET */
dsh->clean_left_offset = svq3_get_ue_golomb(gb);
dsh->clean_left_offset = get_interleaved_ue_golomb(gb);
/* [DIRAC_STD] CLEAN_RIGHT_OFFSET */
dsh->clean_right_offset = svq3_get_ue_golomb(gb);
dsh->clean_right_offset = get_interleaved_ue_golomb(gb);
}

/* [DIRAC_STD] 10.3.8 Signal range. signal_range(video_params)
* WARNING: Some adaptation seems to be done using the
* AVCOL_RANGE_MPEG/JPEG values */
if (get_bits1(gb)) { /* [DIRAC_STD] custom_signal_range_flag */
/* [DIRAC_STD] index */
dsh->pixel_range_index = svq3_get_ue_golomb(gb);
dsh->pixel_range_index = get_interleaved_ue_golomb(gb);

if (dsh->pixel_range_index > 4U)
return AVERROR_INVALIDDATA;

/* This assumes either fullrange or MPEG levels only */
if (!dsh->pixel_range_index) {
luma_offset = svq3_get_ue_golomb(gb);
luma_depth = av_log2(svq3_get_ue_golomb(gb)) + 1;
svq3_get_ue_golomb(gb); /* chroma offset */
svq3_get_ue_golomb(gb); /* chroma excursion */
luma_offset = get_interleaved_ue_golomb(gb);
luma_depth = av_log2(get_interleaved_ue_golomb(gb)) + 1;
get_interleaved_ue_golomb(gb); /* chroma offset */
get_interleaved_ue_golomb(gb); /* chroma excursion */
dsh->color_range = luma_offset ? AVCOL_RANGE_MPEG
: AVCOL_RANGE_JPEG;
}
Expand Down Expand Up @@ -279,7 +279,7 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb,
/* [DIRAC_STD] 10.3.9 Colour specification. colour_spec(video_params) */
if (get_bits1(gb)) { /* [DIRAC_STD] custom_colour_spec_flag */
/* [DIRAC_STD] index */
idx = dsh->color_spec_index = svq3_get_ue_golomb(gb);
idx = dsh->color_spec_index = get_interleaved_ue_golomb(gb);

if (dsh->color_spec_index > 4U)
return AVERROR_INVALIDDATA;
Expand All @@ -291,20 +291,20 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb,
if (!dsh->color_spec_index) {
/* [DIRAC_STD] 10.3.9.1 Colour primaries */
if (get_bits1(gb)) {
idx = svq3_get_ue_golomb(gb);
idx = get_interleaved_ue_golomb(gb);
if (idx < 3U)
dsh->color_primaries = dirac_primaries[idx];
}
/* [DIRAC_STD] 10.3.9.2 Colour matrix */
if (get_bits1(gb)) {
idx = svq3_get_ue_golomb(gb);
idx = get_interleaved_ue_golomb(gb);
if (!idx)
dsh->colorspace = AVCOL_SPC_BT709;
else if (idx == 1)
dsh->colorspace = AVCOL_SPC_BT470BG;
}
/* [DIRAC_STD] 10.3.9.3 Transfer function */
if (get_bits1(gb) && !svq3_get_ue_golomb(gb))
if (get_bits1(gb) && !get_interleaved_ue_golomb(gb))
dsh->color_trc = AVCOL_TRC_BT709;
}
} else {
Expand Down Expand Up @@ -336,13 +336,13 @@ int av_dirac_parse_sequence_header(AVDiracSeqHeader **pdsh,
goto fail;

/* [DIRAC_SPEC] 10.1 Parse Parameters. parse_parameters() */
dsh->version.major = svq3_get_ue_golomb(&gb);
dsh->version.minor = svq3_get_ue_golomb(&gb);
dsh->profile = svq3_get_ue_golomb(&gb);
dsh->level = svq3_get_ue_golomb(&gb);
dsh->version.major = get_interleaved_ue_golomb(&gb);
dsh->version.minor = get_interleaved_ue_golomb(&gb);
dsh->profile = get_interleaved_ue_golomb(&gb);
dsh->level = get_interleaved_ue_golomb(&gb);
/* [DIRAC_SPEC] sequence_header() -> base_video_format as defined in
* 10.2 Base Video Format, table 10.1 Dirac predefined video formats */
video_format = svq3_get_ue_golomb(&gb);
video_format = get_interleaved_ue_golomb(&gb);

if (dsh->version.major < 2 && log_ctx)
av_log(log_ctx, AV_LOG_WARNING, "Stream is old and may not work\n");
Expand Down Expand Up @@ -377,7 +377,7 @@ int av_dirac_parse_sequence_header(AVDiracSeqHeader **pdsh,

/* [DIRAC_STD] picture_coding_mode shall be 0 for fields and 1 for frames
* currently only used to signal field coding */
picture_coding_mode = svq3_get_ue_golomb(&gb);
picture_coding_mode = get_interleaved_ue_golomb(&gb);
if (picture_coding_mode != 0) {
if (log_ctx) {
av_log(log_ctx, AV_LOG_ERROR, "Unsupported picture coding mode %d",
Expand Down
56 changes: 28 additions & 28 deletions libavcodec/diracdec.c
Expand Up @@ -671,9 +671,9 @@ static void decode_component(DiracContext *s, int comp)

align_get_bits(&s->gb);
/* [DIRAC_STD] 13.4.2 subband() */
b->length = svq3_get_ue_golomb(&s->gb);
b->length = get_interleaved_ue_golomb(&s->gb);
if (b->length) {
b->quant = svq3_get_ue_golomb(&s->gb);
b->quant = get_interleaved_ue_golomb(&s->gb);
align_get_bits(&s->gb);
b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8;
b->length = FFMIN(b->length, FFMAX(get_bits_left(&s->gb)/8, 0));
Expand Down Expand Up @@ -1001,18 +1001,18 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
align_get_bits(gb);
/* [DIRAC_STD] 11.2.2 Block parameters. block_parameters() */
/* Luma and Chroma are equal. 11.2.3 */
idx = svq3_get_ue_golomb(gb); /* [DIRAC_STD] index */
idx = get_interleaved_ue_golomb(gb); /* [DIRAC_STD] index */

if (idx > 4) {
av_log(s->avctx, AV_LOG_ERROR, "Block prediction index too high\n");
return AVERROR_INVALIDDATA;
}

if (idx == 0) {
s->plane[0].xblen = svq3_get_ue_golomb(gb);
s->plane[0].yblen = svq3_get_ue_golomb(gb);
s->plane[0].xbsep = svq3_get_ue_golomb(gb);
s->plane[0].ybsep = svq3_get_ue_golomb(gb);
s->plane[0].xblen = get_interleaved_ue_golomb(gb);
s->plane[0].yblen = get_interleaved_ue_golomb(gb);
s->plane[0].xbsep = get_interleaved_ue_golomb(gb);
s->plane[0].ybsep = get_interleaved_ue_golomb(gb);
} else {
/*[DIRAC_STD] preset_block_params(index). Table 11.1 */
s->plane[0].xblen = default_blen[idx-1];
Expand Down Expand Up @@ -1046,7 +1046,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)

/*[DIRAC_STD] 11.2.5 Motion vector precision. motion_vector_precision()
Read motion vector precision */
s->mv_precision = svq3_get_ue_golomb(gb);
s->mv_precision = get_interleaved_ue_golomb(gb);
if (s->mv_precision > 3) {
av_log(s->avctx, AV_LOG_ERROR, "MV precision finer than eighth-pel\n");
return AVERROR_INVALIDDATA;
Expand All @@ -1066,7 +1066,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
/* [DIRAC_STD] zoom_rotate_shear(gparams)
zoom/rotation/shear parameters */
if (get_bits1(gb)) {
s->globalmc[ref].zrs_exp = svq3_get_ue_golomb(gb);
s->globalmc[ref].zrs_exp = get_interleaved_ue_golomb(gb);
s->globalmc[ref].zrs[0][0] = dirac_get_se_golomb(gb);
s->globalmc[ref].zrs[0][1] = dirac_get_se_golomb(gb);
s->globalmc[ref].zrs[1][0] = dirac_get_se_golomb(gb);
Expand All @@ -1077,7 +1077,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
}
/* [DIRAC_STD] perspective(gparams) */
if (get_bits1(gb)) {
s->globalmc[ref].perspective_exp = svq3_get_ue_golomb(gb);
s->globalmc[ref].perspective_exp = get_interleaved_ue_golomb(gb);
s->globalmc[ref].perspective[0] = dirac_get_se_golomb(gb);
s->globalmc[ref].perspective[1] = dirac_get_se_golomb(gb);
}
Expand All @@ -1086,7 +1086,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)

/*[DIRAC_STD] 11.2.7 Picture prediction mode. prediction_mode()
Picture prediction mode, not currently used. */
if (svq3_get_ue_golomb(gb)) {
if (get_interleaved_ue_golomb(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "Unknown picture prediction mode\n");
return AVERROR_INVALIDDATA;
}
Expand All @@ -1098,7 +1098,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
s->weight[1] = 1;

if (get_bits1(gb)) {
s->weight_log2denom = svq3_get_ue_golomb(gb);
s->weight_log2denom = get_interleaved_ue_golomb(gb);
s->weight[0] = dirac_get_se_golomb(gb);
if (s->num_refs == 2)
s->weight[1] = dirac_get_se_golomb(gb);
Expand All @@ -1117,7 +1117,7 @@ static int dirac_unpack_idwt_params(DiracContext *s)
unsigned tmp;

#define CHECKEDREAD(dst, cond, errmsg) \
tmp = svq3_get_ue_golomb(gb); \
tmp = get_interleaved_ue_golomb(gb); \
if (cond) { \
av_log(s->avctx, AV_LOG_ERROR, errmsg); \
return AVERROR_INVALIDDATA; \
Expand Down Expand Up @@ -1151,18 +1151,18 @@ static int dirac_unpack_idwt_params(DiracContext *s)
}
}
else {
s->num_x = svq3_get_ue_golomb(gb);
s->num_y = svq3_get_ue_golomb(gb);
s->num_x = get_interleaved_ue_golomb(gb);
s->num_y = get_interleaved_ue_golomb(gb);
if (s->ld_picture) {
s->lowdelay.bytes.num = svq3_get_ue_golomb(gb);
s->lowdelay.bytes.den = svq3_get_ue_golomb(gb);
s->lowdelay.bytes.num = get_interleaved_ue_golomb(gb);
s->lowdelay.bytes.den = get_interleaved_ue_golomb(gb);
if (s->lowdelay.bytes.den <= 0) {
av_log(s->avctx,AV_LOG_ERROR,"Invalid lowdelay.bytes.den\n");
return AVERROR_INVALIDDATA;
}
} else if (s->hq_picture) {
s->highquality.prefix_bytes = svq3_get_ue_golomb(gb);
s->highquality.size_scaler = svq3_get_ue_golomb(gb);
s->highquality.prefix_bytes = get_interleaved_ue_golomb(gb);
s->highquality.size_scaler = get_interleaved_ue_golomb(gb);
if (s->highquality.prefix_bytes >= INT_MAX / 8) {
av_log(s->avctx,AV_LOG_ERROR,"too many prefix bytes\n");
return AVERROR_INVALIDDATA;
Expand All @@ -1173,11 +1173,11 @@ static int dirac_unpack_idwt_params(DiracContext *s)
if (get_bits1(gb)) {
av_log(s->avctx,AV_LOG_DEBUG,"Low Delay: Has Custom Quantization Matrix!\n");
/* custom quantization matrix */
s->lowdelay.quant[0][0] = svq3_get_ue_golomb(gb);
s->lowdelay.quant[0][0] = get_interleaved_ue_golomb(gb);
for (level = 0; level < s->wavelet_depth; level++) {
s->lowdelay.quant[level][1] = svq3_get_ue_golomb(gb);
s->lowdelay.quant[level][2] = svq3_get_ue_golomb(gb);
s->lowdelay.quant[level][3] = svq3_get_ue_golomb(gb);
s->lowdelay.quant[level][1] = get_interleaved_ue_golomb(gb);
s->lowdelay.quant[level][2] = get_interleaved_ue_golomb(gb);
s->lowdelay.quant[level][3] = get_interleaved_ue_golomb(gb);
}
} else {
if (s->wavelet_depth > 4) {
Expand Down Expand Up @@ -1388,7 +1388,7 @@ static int dirac_unpack_block_motion_data(DiracContext *s)

/* [DIRAC_STD] 12.3.1 Superblock splitting modes. superblock_split_modes()
decode superblock split modes */
ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb)); /* svq3_get_ue_golomb(gb) is the length */
ff_dirac_init_arith_decoder(arith, gb, get_interleaved_ue_golomb(gb)); /* get_interleaved_ue_golomb(gb) is the length */
for (y = 0; y < s->sbheight; y++) {
for (x = 0; x < s->sbwidth; x++) {
unsigned int split = dirac_get_arith_uint(arith, CTX_SB_F1, CTX_SB_DATA);
Expand All @@ -1400,13 +1400,13 @@ static int dirac_unpack_block_motion_data(DiracContext *s)
}

/* setup arith decoding */
ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb));
ff_dirac_init_arith_decoder(arith, gb, get_interleaved_ue_golomb(gb));
for (i = 0; i < s->num_refs; i++) {
ff_dirac_init_arith_decoder(arith + 4 + 2 * i, gb, svq3_get_ue_golomb(gb));
ff_dirac_init_arith_decoder(arith + 5 + 2 * i, gb, svq3_get_ue_golomb(gb));
ff_dirac_init_arith_decoder(arith + 4 + 2 * i, gb, get_interleaved_ue_golomb(gb));
ff_dirac_init_arith_decoder(arith + 5 + 2 * i, gb, get_interleaved_ue_golomb(gb));
}
for (i = 0; i < 3; i++)
ff_dirac_init_arith_decoder(arith+1+i, gb, svq3_get_ue_golomb(gb));
ff_dirac_init_arith_decoder(arith+1+i, gb, get_interleaved_ue_golomb(gb));

for (y = 0; y < s->sbheight; y++)
for (x = 0; x < s->sbwidth; x++) {
Expand Down
6 changes: 3 additions & 3 deletions libavcodec/golomb.h
Expand Up @@ -112,7 +112,7 @@ static inline int get_ue_golomb_31(GetBitContext *gb)
return ff_ue_golomb_vlc_code[buf];
}

static inline unsigned svq3_get_ue_golomb(GetBitContext *gb)
static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb)
{
uint32_t buf;

Expand Down Expand Up @@ -219,7 +219,7 @@ static inline int get_se_golomb_long(GetBitContext *gb)
return ((buf >> 1) ^ sign) + 1;
}

static inline int svq3_get_se_golomb(GetBitContext *gb)
static inline int get_interleaved_se_golomb(GetBitContext *gb)
{
unsigned int buf;

Expand Down Expand Up @@ -254,7 +254,7 @@ static inline int svq3_get_se_golomb(GetBitContext *gb)

static inline int dirac_get_se_golomb(GetBitContext *gb)
{
uint32_t ret = svq3_get_ue_golomb(gb);
uint32_t ret = get_interleaved_ue_golomb(gb);

if (ret) {
int sign = -get_bits1(gb);
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/rv30.c
Expand Up @@ -89,7 +89,7 @@ static int rv30_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t

for(i = 0; i < 4; i++, dst += r->intra_types_stride - 4){
for(j = 0; j < 4; j+= 2){
unsigned code = svq3_get_ue_golomb(gb) << 1;
unsigned code = get_interleaved_ue_golomb(gb) << 1;
if (code > 80U*2U) {
av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction code\n");
return -1;
Expand Down Expand Up @@ -117,7 +117,7 @@ static int rv30_decode_mb_info(RV34DecContext *r)
static const int rv30_b_types[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
MpegEncContext *s = &r->s;
GetBitContext *gb = &s->gb;
unsigned code = svq3_get_ue_golomb(gb);
unsigned code = get_interleaved_ue_golomb(gb);

if (code > 11) {
av_log(s->avctx, AV_LOG_ERROR, "Incorrect MB type code\n");
Expand Down
4 changes: 2 additions & 2 deletions libavcodec/rv34.c
Expand Up @@ -864,8 +864,8 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type)

memset(r->dmv, 0, sizeof(r->dmv));
for(i = 0; i < num_mvs[block_type]; i++){
r->dmv[i][0] = svq3_get_se_golomb(gb);
r->dmv[i][1] = svq3_get_se_golomb(gb);
r->dmv[i][0] = get_interleaved_se_golomb(gb);
r->dmv[i][1] = get_interleaved_se_golomb(gb);
}
switch(block_type){
case RV34_MB_TYPE_INTRA:
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/rv40.c
Expand Up @@ -231,7 +231,7 @@ static int rv40_decode_mb_info(RV34DecContext *r)
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;

if(!r->s.mb_skip_run) {
r->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1;
r->s.mb_skip_run = get_interleaved_ue_golomb(gb) + 1;
if(r->s.mb_skip_run > (unsigned)s->mb_num)
return -1;
}
Expand Down

0 comments on commit b20fe65

Please sign in to comment.