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

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  dirac: use meaningful return values
  flacdec: simplify sample buffer handling
  flacdec: simplify loop in decode_residuals()
  fate: make Ut Video encoder tests use bitexact swscale flags
  build: amrwb: Drop redundant lsp dependency declaration
  fate: fix utvideoenc tests

Conflicts:
	libavcodec/dirac.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-08-21 16:17:13 +02:00
commit 50df56161f
3 changed files with 39 additions and 36 deletions

View File

@ -93,7 +93,7 @@ OBJS-$(CONFIG_AMRNB_DECODER) += amrnbdec.o celp_filters.o \
OBJS-$(CONFIG_AMRWB_DECODER) += amrwbdec.o celp_filters.o \
celp_math.o acelp_filters.o \
acelp_vectors.o \
acelp_pitch_delay.o lsp.o
acelp_pitch_delay.o
OBJS-$(CONFIG_AMV_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o
OBJS-$(CONFIG_AMV_ENCODER) += mjpegenc.o mjpeg.o \
mpegvideo_enc.o motion_est.o \

View File

@ -144,21 +144,21 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
if (source->chroma_format > 2U) {
av_log(avctx, AV_LOG_ERROR, "Unknown chroma format %d\n",
source->chroma_format);
return -1;
return AVERROR_INVALIDDATA;
}
/* [DIRAC_STD] 10.3.4 Scan Format. scan_format(video_params) */
if (get_bits1(gb)) /* [DIRAC_STD] custom_scan_format_flag */
source->interlaced = svq3_get_ue_golomb(gb); /* [DIRAC_STD] SOURCE_SAMPLING */
if (source->interlaced > 1U)
return -1;
return AVERROR_INVALIDDATA;
/* [DIRAC_STD] 10.3.5 Frame Rate. frame_rate(video_params) */
if (get_bits1(gb)) { /* [DIRAC_STD] custom_frame_rate_flag */
source->frame_rate_index = svq3_get_ue_golomb(gb);
if (source->frame_rate_index > 10U)
return -1;
return AVERROR_INVALIDDATA;
if (!source->frame_rate_index){
frame_rate.num = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_RATE_NUMER */
@ -179,7 +179,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
source->aspect_ratio_index = svq3_get_ue_golomb(gb); /* [DIRAC_STD] index */
if (source->aspect_ratio_index > 6U)
return -1;
return AVERROR_INVALIDDATA;
if (!source->aspect_ratio_index) {
avctx->sample_aspect_ratio.num = svq3_get_ue_golomb(gb);
@ -204,7 +204,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
source->pixel_range_index = svq3_get_ue_golomb(gb); /*[DIRAC_STD] index */
if (source->pixel_range_index > 4U)
return -1;
return AVERROR_INVALIDDATA;
/* This assumes either fullrange or MPEG levels only */
if (!source->pixel_range_index) {
@ -232,7 +232,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
idx = source->color_spec_index = svq3_get_ue_golomb(gb); /* [DIRAC_STD] index */
if (source->color_spec_index > 4U)
return -1;
return AVERROR_INVALIDDATA;
avctx->color_primaries = dirac_color_presets[idx].color_primaries;
avctx->colorspace = dirac_color_presets[idx].colorspace;
@ -276,6 +276,7 @@ int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,
{
unsigned version_major;
unsigned video_format, picture_coding_mode;
int ret;
/* [DIRAC_SPEC] 10.1 Parse Parameters. parse_parameters() */
version_major = svq3_get_ue_golomb(gb);
@ -292,18 +293,17 @@ int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,
av_log(avctx, AV_LOG_WARNING, "Stream may have unhandled features\n");
if (video_format > 20U)
return -1;
return AVERROR_INVALIDDATA;
/* Fill in defaults for the source parameters. */
*source = dirac_source_parameters_defaults[video_format];
/*[DIRAC_STD] 10.3 Source Parameters
Override the defaults. */
if (parse_source_parameters(avctx, gb, source))
return -1;
// Override the defaults.
if (ret = parse_source_parameters(avctx, gb, source))
return ret;
if (av_image_check_size(source->width, source->height, 0, avctx))
return -1;
if (ret = av_image_check_size(source->width, source->height, 0, avctx))
return ret;
avcodec_set_dimensions(avctx, source->width, source->height);
@ -313,7 +313,7 @@ int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,
if (picture_coding_mode != 0) {
av_log(avctx, AV_LOG_ERROR, "Unsupported picture coding mode %d",
picture_coding_mode);
return -1;
return AVERROR_INVALIDDATA;
}
return 0;
}

View File

@ -202,10 +202,11 @@ static int get_metadata_size(const uint8_t *buf, int buf_size)
return buf_size - (buf_end - buf);
}
static int decode_residuals(FLACContext *s, int channel, int pred_order)
static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
{
int i, tmp, partition, method_type, rice_order;
int sample = 0, samples;
int rice_bits, rice_esc;
int samples;
method_type = get_bits(&s->gb, 2);
if (method_type > 1) {
@ -223,17 +224,20 @@ static int decode_residuals(FLACContext *s, int channel, int pred_order)
return -1;
}
sample=
rice_bits = 4 + method_type;
rice_esc = (1 << rice_bits) - 1;
decoded += pred_order;
i= pred_order;
for (partition = 0; partition < (1 << rice_order); partition++) {
tmp = get_bits(&s->gb, method_type == 0 ? 4 : 5);
if (tmp == (method_type == 0 ? 15 : 31)) {
tmp = get_bits(&s->gb, rice_bits);
if (tmp == rice_esc) {
tmp = get_bits(&s->gb, 5);
for (; i < samples; i++, sample++)
s->decoded[channel][sample] = get_sbits_long(&s->gb, tmp);
for (; i < samples; i++)
*decoded++ = get_sbits_long(&s->gb, tmp);
} else {
for (; i < samples; i++, sample++) {
s->decoded[channel][sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
for (; i < samples; i++) {
*decoded++ = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
}
}
i= 0;
@ -242,11 +246,10 @@ static int decode_residuals(FLACContext *s, int channel, int pred_order)
return 0;
}
static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order,
int bps)
static int decode_subframe_fixed(FLACContext *s, int32_t *decoded,
int pred_order, int bps)
{
const int blocksize = s->blocksize;
int32_t *decoded = s->decoded[channel];
int a, b, c, d, i;
/* warm up samples */
@ -254,7 +257,7 @@ static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order,
decoded[i] = get_sbits_long(&s->gb, bps);
}
if (decode_residuals(s, channel, pred_order) < 0)
if (decode_residuals(s, decoded, pred_order) < 0)
return -1;
if (pred_order > 0)
@ -293,13 +296,12 @@ static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order,
return 0;
}
static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order,
static int decode_subframe_lpc(FLACContext *s, int32_t *decoded, int pred_order,
int bps)
{
int i;
int coeff_prec, qlevel;
int coeffs[32];
int32_t *decoded = s->decoded[channel];
/* warm up samples */
for (i = 0; i < pred_order; i++) {
@ -322,7 +324,7 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order,
coeffs[pred_order - i - 1] = get_sbits(&s->gb, coeff_prec);
}
if (decode_residuals(s, channel, pred_order) < 0)
if (decode_residuals(s, decoded, pred_order) < 0)
return -1;
s->dsp.lpc(decoded, coeffs, pred_order, qlevel, s->blocksize);
@ -332,6 +334,7 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order,
static inline int decode_subframe(FLACContext *s, int channel)
{
int32_t *decoded = s->decoded[channel];
int type, wasted = 0;
int bps = s->bps;
int i, tmp;
@ -374,15 +377,15 @@ static inline int decode_subframe(FLACContext *s, int channel)
if (type == 0) {
tmp = get_sbits_long(&s->gb, bps);
for (i = 0; i < s->blocksize; i++)
s->decoded[channel][i] = tmp;
decoded[i] = tmp;
} else if (type == 1) {
for (i = 0; i < s->blocksize; i++)
s->decoded[channel][i] = get_sbits_long(&s->gb, bps);
decoded[i] = get_sbits_long(&s->gb, bps);
} else if ((type >= 8) && (type <= 12)) {
if (decode_subframe_fixed(s, channel, type & ~0x8, bps) < 0)
if (decode_subframe_fixed(s, decoded, type & ~0x8, bps) < 0)
return -1;
} else if (type >= 32) {
if (decode_subframe_lpc(s, channel, (type & ~0x20)+1, bps) < 0)
if (decode_subframe_lpc(s, decoded, (type & ~0x20)+1, bps) < 0)
return -1;
} else {
av_log(s->avctx, AV_LOG_ERROR, "invalid coding type\n");
@ -392,7 +395,7 @@ static inline int decode_subframe(FLACContext *s, int channel)
if (wasted) {
int i;
for (i = 0; i < s->blocksize; i++)
s->decoded[channel][i] <<= wasted;
decoded[i] <<= wasted;
}
return 0;