* qatar/master: Remove h264_lowres_idct_put/add functions Remove snow/dwt test program h264: remove some disabled code Fix incorrect max_lowres values matroskadec: fix integer underflow if header length < probe length. cosmetics: indentation eac3enc: use frame exponent strategy when applicable. cosmetics: rename eac3dec_data.c/h to eac3_data.c/h since the tables will also be used in the E-AC-3 encoder. dsputil: fix ff_check_alignment() Conflicts: libavcodec/Makefile libavcodec/h264idct_template.c Merged-by: Michael Niedermayer <michaelni@gmx.at>tags/n0.9
@@ -127,9 +127,9 @@ OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o | |||
OBJS-$(CONFIG_DVVIDEO_DECODER) += dv.o dvdata.o | |||
OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o dvdata.o | |||
OBJS-$(CONFIG_DXA_DECODER) += dxa.o | |||
OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3dec_data.o | |||
OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3_data.o | |||
OBJS-$(CONFIG_EAC3_ENCODER) += eac3enc.o ac3enc.o ac3enc_float.o \ | |||
ac3tab.o ac3.o kbdwin.o | |||
ac3tab.o ac3.o kbdwin.o eac3_data.o | |||
OBJS-$(CONFIG_EACMV_DECODER) += eacmv.o | |||
OBJS-$(CONFIG_EAMAD_DECODER) += eamad.o eaidct.o mpeg12.o \ | |||
mpeg12data.o mpegvideo.o \ | |||
@@ -194,6 +194,7 @@ void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) | |||
{ | |||
int blk, ch; | |||
int got_cpl_snr; | |||
int num_cpl_blocks; | |||
/* set coupling use flags for each block/channel */ | |||
/* TODO: turn coupling on/off and adjust start band based on bit usage */ | |||
@@ -206,12 +207,14 @@ void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) | |||
/* enable coupling for each block if at least 2 channels have coupling | |||
enabled for that block */ | |||
got_cpl_snr = 0; | |||
num_cpl_blocks = 0; | |||
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | |||
AC3Block *block = &s->blocks[blk]; | |||
block->num_cpl_channels = 0; | |||
for (ch = 1; ch <= s->fbw_channels; ch++) | |||
block->num_cpl_channels += block->channel_in_cpl[ch]; | |||
block->cpl_in_use = block->num_cpl_channels > 1; | |||
num_cpl_blocks += block->cpl_in_use; | |||
if (!block->cpl_in_use) { | |||
block->num_cpl_channels = 0; | |||
for (ch = 1; ch <= s->fbw_channels; ch++) | |||
@@ -237,6 +240,8 @@ void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) | |||
block->new_snr_offsets = 0; | |||
} | |||
} | |||
if (!num_cpl_blocks) | |||
s->cpl_on = 0; | |||
/* set bandwidth for each channel */ | |||
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { | |||
@@ -301,6 +306,9 @@ static av_cold void exponent_init(AC3EncodeContext *s) | |||
} | |||
/* LFE */ | |||
exponent_group_tab[0][0][7] = 2; | |||
if (CONFIG_EAC3_ENCODER && s->eac3) | |||
ff_eac3_exponent_init(); | |||
} | |||
@@ -342,8 +350,15 @@ static void compute_exp_strategy(AC3EncodeContext *s) | |||
exp_strategy[0] = EXP_NEW; | |||
exp += AC3_MAX_COEFS; | |||
for (blk = 1; blk < AC3_MAX_BLOCKS; blk++, exp += AC3_MAX_COEFS) { | |||
if ((ch == CPL_CH && (!s->blocks[blk].cpl_in_use || !s->blocks[blk-1].cpl_in_use)) || | |||
(ch > CPL_CH && (s->blocks[blk].channel_in_cpl[ch] != s->blocks[blk-1].channel_in_cpl[ch]))) { | |||
if (ch == CPL_CH) { | |||
if (!s->blocks[blk-1].cpl_in_use) { | |||
exp_strategy[blk] = EXP_NEW; | |||
continue; | |||
} else if (!s->blocks[blk].cpl_in_use) { | |||
exp_strategy[blk] = EXP_REUSE; | |||
continue; | |||
} | |||
} else if (s->blocks[blk].channel_in_cpl[ch] != s->blocks[blk-1].channel_in_cpl[ch]) { | |||
exp_strategy[blk] = EXP_NEW; | |||
continue; | |||
} | |||
@@ -377,6 +392,10 @@ static void compute_exp_strategy(AC3EncodeContext *s) | |||
for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) | |||
s->exp_strategy[ch][blk] = EXP_REUSE; | |||
} | |||
/* for E-AC-3, determine frame exponent strategy */ | |||
if (CONFIG_EAC3_ENCODER && s->eac3) | |||
ff_eac3_get_frame_exp_strategy(s); | |||
} | |||
@@ -611,8 +630,12 @@ static void count_frame_bits_fixed(AC3EncodeContext *s) | |||
frame_bits += 2; | |||
frame_bits += 10; | |||
/* exponent strategy */ | |||
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | |||
frame_bits += 2 * s->fbw_channels + s->lfe_on; | |||
if (s->use_frame_exp_strategy) | |||
frame_bits += 5 * s->fbw_channels; | |||
else | |||
frame_bits += AC3_MAX_BLOCKS * 2 * s->fbw_channels; | |||
if (s->lfe_on) | |||
frame_bits += AC3_MAX_BLOCKS; | |||
/* converter exponent strategy */ | |||
frame_bits += s->fbw_channels * 5; | |||
/* snr offsets */ | |||
@@ -735,8 +758,14 @@ static void count_frame_bits(AC3EncodeContext *s) | |||
} | |||
} | |||
/* coupling exponent strategy */ | |||
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | |||
frame_bits += 2 * s->blocks[blk].cpl_in_use; | |||
if (s->cpl_on) { | |||
if (s->use_frame_exp_strategy) { | |||
frame_bits += 5 * s->cpl_on; | |||
} else { | |||
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | |||
frame_bits += 2 * s->blocks[blk].cpl_in_use; | |||
} | |||
} | |||
} else { | |||
if (opt->audio_production_info) | |||
frame_bits += 7; | |||
@@ -218,6 +218,8 @@ typedef struct AC3EncodeContext { | |||
uint8_t *cpl_coord_mant_buffer; | |||
uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies | |||
uint8_t frame_exp_strategy[AC3_MAX_CHANNELS]; ///< frame exp strategy index | |||
int use_frame_exp_strategy; ///< indicates use of frame exp strategy | |||
uint8_t exp_ref_block[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< reference blocks for EXP_REUSE | |||
uint8_t *ref_bap [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap) | |||
int ref_bap_set; ///< indicates if ref_bap pointers have been set | |||
@@ -2811,9 +2811,9 @@ av_cold void dsputil_static_init(void) | |||
int ff_check_alignment(void){ | |||
static int did_fail=0; | |||
LOCAL_ALIGNED_16(int, aligned); | |||
LOCAL_ALIGNED_16(int, aligned, [4]); | |||
if((intptr_t)&aligned & 15){ | |||
if((intptr_t)aligned & 15){ | |||
if(!did_fail){ | |||
#if HAVE_MMX || HAVE_ALTIVEC | |||
av_log(NULL, AV_LOG_ERROR, | |||
@@ -2851,29 +2851,8 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) | |||
#endif //CONFIG_ENCODERS | |||
if(avctx->lowres==1){ | |||
if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO || !CONFIG_H264_DECODER){ | |||
c->idct_put= ff_jref_idct4_put; | |||
c->idct_add= ff_jref_idct4_add; | |||
}else{ | |||
if (avctx->codec_id != CODEC_ID_H264) { | |||
c->idct_put= ff_h264_lowres_idct_put_8_c; | |||
c->idct_add= ff_h264_lowres_idct_add_8_c; | |||
} else { | |||
switch (avctx->bits_per_raw_sample) { | |||
case 9: | |||
c->idct_put= ff_h264_lowres_idct_put_9_c; | |||
c->idct_add= ff_h264_lowres_idct_add_9_c; | |||
break; | |||
case 10: | |||
c->idct_put= ff_h264_lowres_idct_put_10_c; | |||
c->idct_add= ff_h264_lowres_idct_add_10_c; | |||
break; | |||
default: | |||
c->idct_put= ff_h264_lowres_idct_put_8_c; | |||
c->idct_add= ff_h264_lowres_idct_add_8_c; | |||
} | |||
} | |||
} | |||
c->idct_put= ff_jref_idct4_put; | |||
c->idct_add= ff_jref_idct4_add; | |||
c->idct = j_rev_dct4; | |||
c->idct_permutation_type= FF_NO_IDCT_PERM; | |||
}else if(avctx->lowres==2){ | |||
@@ -58,8 +58,6 @@ void ff_h264_idct8_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride) | |||
void ff_h264_idct_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\ | |||
void ff_h264_idct8_dc_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\ | |||
void ff_h264_idct_dc_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int stride);\ | |||
void ff_h264_lowres_idct_add_ ## depth ## _c(uint8_t *dst, int stride, DCTELEM *block);\ | |||
void ff_h264_lowres_idct_put_ ## depth ## _c(uint8_t *dst, int stride, DCTELEM *block);\ | |||
void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ | |||
void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ | |||
void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ | |||
@@ -1,5 +1,5 @@ | |||
/* | |||
* E-AC-3 decoder tables | |||
* E-AC-3 tables | |||
* Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> | |||
* | |||
* This file is part of FFmpeg. | |||
@@ -24,7 +24,7 @@ | |||
* Tables taken directly from the E-AC-3 spec. | |||
*/ | |||
#include "eac3dec_data.h" | |||
#include "eac3_data.h" | |||
#include "ac3.h" | |||
const uint8_t ff_eac3_bits_vs_hebap[20] = { |
@@ -1,5 +1,5 @@ | |||
/* | |||
* E-AC-3 decoder tables | |||
* E-AC-3 tables | |||
* Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> | |||
* | |||
* This file is part of FFmpeg. | |||
@@ -19,8 +19,8 @@ | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
*/ | |||
#ifndef AVCODEC_EAC3DEC_DATA_H | |||
#define AVCODEC_EAC3DEC_DATA_H | |||
#ifndef AVCODEC_EAC3_DATA_H | |||
#define AVCODEC_EAC3_DATA_H | |||
#include <stdint.h> | |||
@@ -33,4 +33,4 @@ extern const int16_t (* const ff_eac3_mantissa_vq[8])[6]; | |||
extern const uint8_t ff_eac3_frm_expstr[32][6]; | |||
extern const float ff_eac3_spx_atten_tab[32][3]; | |||
#endif /* AVCODEC_EAC3DEC_DATA_H */ | |||
#endif /* AVCODEC_EAC3_DATA_H */ |
@@ -51,7 +51,7 @@ | |||
#include "ac3_parser.h" | |||
#include "ac3dec.h" | |||
#include "ac3dec_data.h" | |||
#include "eac3dec_data.h" | |||
#include "eac3_data.h" | |||
/** gain adaptive quantization mode */ | |||
typedef enum { | |||
@@ -27,6 +27,7 @@ | |||
#define CONFIG_AC3ENC_FLOAT 1 | |||
#include "ac3enc.h" | |||
#include "eac3enc.h" | |||
#include "eac3_data.h" | |||
#define AC3ENC_TYPE AC3ENC_TYPE_EAC3 | |||
@@ -35,6 +36,51 @@ static const AVClass eac3enc_class = { "E-AC-3 Encoder", av_default_item_name, | |||
eac3_options, LIBAVUTIL_VERSION_INT }; | |||
/** | |||
* LUT for finding a matching frame exponent strategy index from a set of | |||
* exponent strategies for a single channel across all 6 blocks. | |||
*/ | |||
static int8_t eac3_frame_expstr_index_tab[3][4][4][4][4][4]; | |||
void ff_eac3_exponent_init(void) | |||
{ | |||
int i; | |||
memset(eac3_frame_expstr_index_tab, -1, sizeof(eac3_frame_expstr_index_tab)); | |||
for (i = 0; i < 32; i++) { | |||
eac3_frame_expstr_index_tab[ff_eac3_frm_expstr[i][0]-1] | |||
[ff_eac3_frm_expstr[i][1]] | |||
[ff_eac3_frm_expstr[i][2]] | |||
[ff_eac3_frm_expstr[i][3]] | |||
[ff_eac3_frm_expstr[i][4]] | |||
[ff_eac3_frm_expstr[i][5]] = i; | |||
} | |||
} | |||
void ff_eac3_get_frame_exp_strategy(AC3EncodeContext *s) | |||
{ | |||
int ch; | |||
s->use_frame_exp_strategy = 1; | |||
for (ch = !s->cpl_on; ch <= s->fbw_channels; ch++) { | |||
int expstr = eac3_frame_expstr_index_tab[s->exp_strategy[ch][0]-1] | |||
[s->exp_strategy[ch][1]] | |||
[s->exp_strategy[ch][2]] | |||
[s->exp_strategy[ch][3]] | |||
[s->exp_strategy[ch][4]] | |||
[s->exp_strategy[ch][5]]; | |||
if (expstr < 0) { | |||
s->use_frame_exp_strategy = 0; | |||
break; | |||
} | |||
s->frame_exp_strategy[ch] = expstr; | |||
} | |||
} | |||
void ff_eac3_set_cpl_states(AC3EncodeContext *s) | |||
{ | |||
int ch, blk; | |||
@@ -98,7 +144,7 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) | |||
put_bits(&s->pb, 1, 0); /* no additional bit stream info */ | |||
/* frame header */ | |||
put_bits(&s->pb, 1, 1); /* exponent strategy syntax = each block */ | |||
put_bits(&s->pb, 1, !s->use_frame_exp_strategy);/* exponent strategy syntax */ | |||
put_bits(&s->pb, 1, 0); /* aht enabled = no */ | |||
put_bits(&s->pb, 2, 0); /* snr offset strategy = 1 */ | |||
put_bits(&s->pb, 1, 0); /* transient pre-noise processing enabled = no */ | |||
@@ -120,16 +166,25 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) | |||
} | |||
} | |||
/* exponent strategy */ | |||
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | |||
for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) | |||
put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); | |||
if (s->use_frame_exp_strategy) { | |||
for (ch = !s->cpl_on; ch <= s->fbw_channels; ch++) | |||
put_bits(&s->pb, 5, s->frame_exp_strategy[ch]); | |||
} else { | |||
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | |||
for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) | |||
put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); | |||
} | |||
if (s->lfe_on) { | |||
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) | |||
put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]); | |||
} | |||
/* E-AC-3 to AC-3 converter exponent strategy (unfortunately not optional...) */ | |||
for (ch = 1; ch <= s->fbw_channels; ch++) | |||
put_bits(&s->pb, 5, 0); | |||
for (ch = 1; ch <= s->fbw_channels; ch++) { | |||
if (s->use_frame_exp_strategy) | |||
put_bits(&s->pb, 5, s->frame_exp_strategy[ch]); | |||
else | |||
put_bits(&s->pb, 5, 0); | |||
} | |||
/* snr offsets */ | |||
put_bits(&s->pb, 6, s->coarse_snr_offset); | |||
put_bits(&s->pb, 4, s->fine_snr_offset[1]); | |||
@@ -29,6 +29,16 @@ | |||
#include "ac3enc.h" | |||
/** | |||
* Initialize E-AC-3 exponent tables. | |||
*/ | |||
void ff_eac3_exponent_init(void); | |||
/** | |||
* Determine frame exponent strategy use and indices. | |||
*/ | |||
void ff_eac3_get_frame_exp_strategy(AC3EncodeContext *s); | |||
/** | |||
* Set coupling states. | |||
* This determines whether certain flags must be written to the bitstream or | |||
@@ -3463,52 +3463,6 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){ | |||
} | |||
} | |||
} | |||
#if 0 | |||
for(;s->mb_y < s->mb_height; s->mb_y++){ | |||
for(;s->mb_x < s->mb_width; s->mb_x++){ | |||
int ret= decode_mb(h); | |||
ff_h264_hl_decode_mb(h); | |||
if(ret<0){ | |||
av_log(s->avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y); | |||
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask); | |||
return -1; | |||
} | |||
if(++s->mb_x >= s->mb_width){ | |||
s->mb_x=0; | |||
if(++s->mb_y >= s->mb_height){ | |||
if(get_bits_count(s->gb) == s->gb.size_in_bits){ | |||
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask); | |||
return 0; | |||
}else{ | |||
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask); | |||
return -1; | |||
} | |||
} | |||
} | |||
if(get_bits_count(s->?gb) >= s->gb?.size_in_bits){ | |||
if(get_bits_count(s->gb) == s->gb.size_in_bits){ | |||
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask); | |||
return 0; | |||
}else{ | |||
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask); | |||
return -1; | |||
} | |||
} | |||
} | |||
s->mb_x=0; | |||
ff_draw_horiz_band(s, 16*s->mb_y, 16); | |||
} | |||
#endif | |||
} | |||
/** | |||
@@ -3976,109 +3930,6 @@ int main(void){ | |||
STOP_TIMER("get_se_golomb"); | |||
} | |||
#if 0 | |||
printf("testing 4x4 (I)DCT\n"); | |||
DCTELEM block[16]; | |||
uint8_t src[16], ref[16]; | |||
uint64_t error= 0, max_error=0; | |||
for(i=0; i<COUNT; i++){ | |||
int j; | |||
// printf("%d %d %d\n", r1, r2, (r2-r1)*16); | |||
for(j=0; j<16; j++){ | |||
ref[j]= random()%255; | |||
src[j]= random()%255; | |||
} | |||
h264_diff_dct_c(block, src, ref, 4); | |||
//normalize | |||
for(j=0; j<16; j++){ | |||
// printf("%d ", block[j]); | |||
block[j]= block[j]*4; | |||
if(j&1) block[j]= (block[j]*4 + 2)/5; | |||
if(j&4) block[j]= (block[j]*4 + 2)/5; | |||
} | |||
// printf("\n"); | |||
h->h264dsp.h264_idct_add(ref, block, 4); | |||
/* for(j=0; j<16; j++){ | |||
printf("%d ", ref[j]); | |||
} | |||
printf("\n");*/ | |||
for(j=0; j<16; j++){ | |||
int diff= FFABS(src[j] - ref[j]); | |||
error+= diff*diff; | |||
max_error= FFMAX(max_error, diff); | |||
} | |||
} | |||
printf("error=%f max_error=%d\n", ((float)error)/COUNT/16, (int)max_error ); | |||
printf("testing quantizer\n"); | |||
for(qp=0; qp<52; qp++){ | |||
for(i=0; i<16; i++) | |||
src1_block[i]= src2_block[i]= random()%255; | |||
} | |||
printf("Testing NAL layer\n"); | |||
uint8_t bitstream[COUNT]; | |||
uint8_t nal[COUNT*2]; | |||
H264Context h; | |||
memset(&h, 0, sizeof(H264Context)); | |||
for(i=0; i<COUNT; i++){ | |||
int zeros= i; | |||
int nal_length; | |||
int consumed; | |||
int out_length; | |||
uint8_t *out; | |||
int j; | |||
for(j=0; j<COUNT; j++){ | |||
bitstream[j]= (random() % 255) + 1; | |||
} | |||
for(j=0; j<zeros; j++){ | |||
int pos= random() % COUNT; | |||
while(bitstream[pos] == 0){ | |||
pos++; | |||
pos %= COUNT; | |||
} | |||
bitstream[pos]=0; | |||
} | |||
START_TIMER | |||
nal_length= encode_nal(&h, nal, bitstream, COUNT, COUNT*2); | |||
if(nal_length<0){ | |||
printf("encoding failed\n"); | |||
return -1; | |||
} | |||
out= ff_h264_decode_nal(&h, nal, &out_length, &consumed, nal_length); | |||
STOP_TIMER("NAL") | |||
if(out_length != COUNT){ | |||
printf("incorrect length %d %d\n", out_length, COUNT); | |||
return -1; | |||
} | |||
if(consumed != nal_length){ | |||
printf("incorrect consumed length %d %d\n", nal_length, consumed); | |||
return -1; | |||
} | |||
if(memcmp(bitstream, out, COUNT)){ | |||
printf("mismatch\n"); | |||
return -1; | |||
} | |||
} | |||
#endif | |||
printf("Testing RBSP\n"); | |||
@@ -46,57 +46,46 @@ static const uint8_t scan8[16*3]={ | |||
}; | |||
#endif | |||
static av_always_inline void FUNCC(idct_internal)(uint8_t *p_dst, DCTELEM *p_block, int stride, int block_stride, int shift, int add){ | |||
void FUNCC(ff_h264_idct_add)(uint8_t *_dst, DCTELEM *_block, int stride) | |||
{ | |||
int i; | |||
INIT_CLIP | |||
pixel *dst = (pixel*)p_dst; | |||
dctcoef *block = (dctcoef*)p_block; | |||
pixel *dst = (pixel*)_dst; | |||
dctcoef *block = (dctcoef*)_block; | |||
stride >>= sizeof(pixel)-1; | |||
block[0] += 1<<(shift-1); | |||
block[0] += 1 << 5; | |||
for(i=0; i<4; i++){ | |||
const int z0= block[i + block_stride*0] + block[i + block_stride*2]; | |||
const int z1= block[i + block_stride*0] - block[i + block_stride*2]; | |||
const int z2= (block[i + block_stride*1]>>1) - block[i + block_stride*3]; | |||
const int z3= block[i + block_stride*1] + (block[i + block_stride*3]>>1); | |||
block[i + block_stride*0]= z0 + z3; | |||
block[i + block_stride*1]= z1 + z2; | |||
block[i + block_stride*2]= z1 - z2; | |||
block[i + block_stride*3]= z0 - z3; | |||
const int z0= block[i + 4*0] + block[i + 4*2]; | |||
const int z1= block[i + 4*0] - block[i + 4*2]; | |||
const int z2= (block[i + 4*1]>>1) - block[i + 4*3]; | |||
const int z3= block[i + 4*1] + (block[i + 4*3]>>1); | |||
block[i + 4*0]= z0 + z3; | |||
block[i + 4*1]= z1 + z2; | |||
block[i + 4*2]= z1 - z2; | |||
block[i + 4*3]= z0 - z3; | |||
} | |||
for(i=0; i<4; i++){ | |||
const int z0= block[0 + block_stride*i] + block[2 + block_stride*i]; | |||
const int z1= block[0 + block_stride*i] - block[2 + block_stride*i]; | |||
const int z2= (block[1 + block_stride*i]>>1) - block[3 + block_stride*i]; | |||
const int z3= block[1 + block_stride*i] + (block[3 + block_stride*i]>>1); | |||
dst[i + 0*stride]= CLIP(add*dst[i + 0*stride] + ((z0 + z3) >> shift)); | |||
dst[i + 1*stride]= CLIP(add*dst[i + 1*stride] + ((z1 + z2) >> shift)); | |||
dst[i + 2*stride]= CLIP(add*dst[i + 2*stride] + ((z1 - z2) >> shift)); | |||
dst[i + 3*stride]= CLIP(add*dst[i + 3*stride] + ((z0 - z3) >> shift)); | |||
const int z0= block[0 + 4*i] + block[2 + 4*i]; | |||
const int z1= block[0 + 4*i] - block[2 + 4*i]; | |||
const int z2= (block[1 + 4*i]>>1) - block[3 + 4*i]; | |||
const int z3= block[1 + 4*i] + (block[3 + 4*i]>>1); | |||
dst[i + 0*stride]= CLIP(dst[i + 0*stride] + ((z0 + z3) >> 6)); | |||
dst[i + 1*stride]= CLIP(dst[i + 1*stride] + ((z1 + z2) >> 6)); | |||
dst[i + 2*stride]= CLIP(dst[i + 2*stride] + ((z1 - z2) >> 6)); | |||
dst[i + 3*stride]= CLIP(dst[i + 3*stride] + ((z0 - z3) >> 6)); | |||
} | |||
} | |||
void FUNCC(ff_h264_idct_add)(uint8_t *dst, DCTELEM *block, int stride){ | |||
FUNCC(idct_internal)(dst, block, stride, 4, 6, 1); | |||
} | |||
void FUNCC(ff_h264_lowres_idct_add)(uint8_t *dst, int stride, DCTELEM *block){ | |||
FUNCC(idct_internal)(dst, block, stride, 8, 3, 1); | |||
} | |||
void FUNCC(ff_h264_lowres_idct_put)(uint8_t *dst, int stride, DCTELEM *block){ | |||
FUNCC(idct_internal)(dst, block, stride, 8, 3, 0); | |||
} | |||
void FUNCC(ff_h264_idct8_add)(uint8_t *p_dst, DCTELEM *p_block, int stride){ | |||
void FUNCC(ff_h264_idct8_add)(uint8_t *_dst, DCTELEM *_block, int stride){ | |||
int i; | |||
INIT_CLIP | |||
pixel *dst = (pixel*)p_dst; | |||
dctcoef *block = (dctcoef*)p_block; | |||
pixel *dst = (pixel*)_dst; | |||
dctcoef *block = (dctcoef*)_block; | |||
stride >>= sizeof(pixel)-1; | |||
block[0] += 32; | |||
@@ -200,7 +189,7 @@ void FUNCC(ff_h264_idct_add16)(uint8_t *dst, const int *block_offset, DCTELEM *b | |||
int nnz = nnzc[ scan8[i] ]; | |||
if(nnz){ | |||
if(nnz==1 && ((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride); | |||
else FUNCC(idct_internal )(dst + block_offset[i], block + i*16*sizeof(pixel), stride, 4, 6, 1); | |||
else FUNCC(ff_h264_idct_add )(dst + block_offset[i], block + i*16*sizeof(pixel), stride); | |||
} | |||
} | |||
} | |||
@@ -208,7 +197,7 @@ void FUNCC(ff_h264_idct_add16)(uint8_t *dst, const int *block_offset, DCTELEM *b | |||
void FUNCC(ff_h264_idct_add16intra)(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[15*8]){ | |||
int i; | |||
for(i=0; i<16; i++){ | |||
if(nnzc[ scan8[i] ]) FUNCC(idct_internal )(dst + block_offset[i], block + i*16*sizeof(pixel), stride, 4, 6, 1); | |||
if(nnzc[ scan8[i] ]) FUNCC(ff_h264_idct_add )(dst + block_offset[i], block + i*16*sizeof(pixel), stride); | |||
else if(((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride); | |||
} | |||
} | |||
@@ -174,6 +174,5 @@ AVCodec ff_kgv1_decoder = { | |||
NULL, | |||
decode_end, | |||
decode_frame, | |||
.max_lowres = 1, | |||
.long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"), | |||
}; |
@@ -931,6 +931,8 @@ static int matroska_probe(AVProbeData *p) | |||
* Not fully fool-proof, but good enough. */ | |||
for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++) { | |||
int probelen = strlen(matroska_doctypes[i]); | |||
if (total < probelen) | |||
continue; | |||
for (n = 4+size; n <= 4+size+total-probelen; n++) | |||
if (!memcmp(p->buf+n, matroska_doctypes[i], probelen)) | |||
return AVPROBE_SCORE_MAX; | |||