fixing custom quantizer matrix decoding
minor optimizations Originally committed as revision 993 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
3994623df2
commit
3a3d3a42c2
@ -1122,6 +1122,7 @@ static void h263_encode_motion(MpegEncContext * s, int val, int f_code)
|
|||||||
put_bits(&s->pb, bit_size, bits);
|
put_bits(&s->pb, bit_size, bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Encode MV differences on H.263+ with Unrestricted MV mode */
|
/* Encode MV differences on H.263+ with Unrestricted MV mode */
|
||||||
@ -2688,7 +2689,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s,
|
|||||||
|
|
||||||
/* decode each block */
|
/* decode each block */
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
int ret= mpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, 1);
|
int ret= mpeg4_decode_block(s, block[i], i, cbp&32, 1);
|
||||||
if(ret==DECODING_AC_LOST){
|
if(ret==DECODING_AC_LOST){
|
||||||
fprintf(stderr, "texture corrupted at %d %d (trying to continue with mc/dc only)\n", s->mb_x, s->mb_y);
|
fprintf(stderr, "texture corrupted at %d %d (trying to continue with mc/dc only)\n", s->mb_x, s->mb_y);
|
||||||
s->decoding_error=DECODING_AC_LOST;
|
s->decoding_error=DECODING_AC_LOST;
|
||||||
@ -2698,6 +2699,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s,
|
|||||||
s->decoding_error=DECODING_ACDC_LOST;
|
s->decoding_error=DECODING_ACDC_LOST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
cbp+=cbp;
|
||||||
}
|
}
|
||||||
}else if(!s->mb_intra){
|
}else if(!s->mb_intra){
|
||||||
// s->mcsel= 0; //FIXME do we need to init that
|
// s->mcsel= 0; //FIXME do we need to init that
|
||||||
@ -2711,12 +2713,13 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s,
|
|||||||
if(s->decoding_error==0 && cbp){
|
if(s->decoding_error==0 && cbp){
|
||||||
/* decode each block */
|
/* decode each block */
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
int ret= mpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, 0);
|
int ret= mpeg4_decode_block(s, block[i], i, cbp&32, 0);
|
||||||
if(ret==DECODING_AC_LOST){
|
if(ret==DECODING_AC_LOST){
|
||||||
fprintf(stderr, "texture corrupted at %d %d (trying to continue with mc/dc only)\n", s->mb_x, s->mb_y);
|
fprintf(stderr, "texture corrupted at %d %d (trying to continue with mc/dc only)\n", s->mb_x, s->mb_y);
|
||||||
s->decoding_error=DECODING_AC_LOST;
|
s->decoding_error=DECODING_AC_LOST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
cbp+=cbp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2727,7 +2730,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s,
|
|||||||
|
|
||||||
/* decode each block */
|
/* decode each block */
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
int ret= mpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, 1);
|
int ret= mpeg4_decode_block(s, block[i], i, cbp&32, 1);
|
||||||
if(ret==DECODING_AC_LOST){
|
if(ret==DECODING_AC_LOST){
|
||||||
fprintf(stderr, "texture corrupted at %d %d (trying to continue with dc only)\n", s->mb_x, s->mb_y);
|
fprintf(stderr, "texture corrupted at %d %d (trying to continue with dc only)\n", s->mb_x, s->mb_y);
|
||||||
s->decoding_error=DECODING_AC_LOST;
|
s->decoding_error=DECODING_AC_LOST;
|
||||||
@ -2736,6 +2739,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s,
|
|||||||
fprintf(stderr, "dc corrupted at %d %d\n", s->mb_x, s->mb_y);
|
fprintf(stderr, "dc corrupted at %d %d\n", s->mb_x, s->mb_y);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
cbp+=cbp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3162,13 +3166,15 @@ intra:
|
|||||||
/* decode each block */
|
/* decode each block */
|
||||||
if (s->h263_pred) {
|
if (s->h263_pred) {
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
if (mpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, 1) < 0)
|
if (mpeg4_decode_block(s, block[i], i, cbp&32, 1) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
cbp+=cbp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
if (h263_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1) < 0)
|
if (h263_decode_block(s, block[i], i, cbp&32) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
cbp+=cbp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -3177,13 +3183,15 @@ intra:
|
|||||||
/* decode each block */
|
/* decode each block */
|
||||||
if (s->h263_pred) {
|
if (s->h263_pred) {
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
if (mpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, 0) < 0)
|
if (mpeg4_decode_block(s, block[i], i, cbp&32, 0) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
cbp+=cbp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
if (h263_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1) < 0)
|
if (h263_decode_block(s, block[i], i, cbp&32) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
cbp+=cbp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -3416,9 +3424,7 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
|
|||||||
goto not_coded;
|
goto not_coded;
|
||||||
rl = &rl_intra;
|
rl = &rl_intra;
|
||||||
rl_vlc = rl_intra.rl_vlc[0];
|
rl_vlc = rl_intra.rl_vlc[0];
|
||||||
if(s->alternate_scan)
|
if (s->ac_pred) {
|
||||||
scan_table = s->intra_v_scantable.permutated; /* left */
|
|
||||||
else if (s->ac_pred) {
|
|
||||||
if (dc_pred_dir == 0)
|
if (dc_pred_dir == 0)
|
||||||
scan_table = s->intra_v_scantable.permutated; /* left */
|
scan_table = s->intra_v_scantable.permutated; /* left */
|
||||||
else
|
else
|
||||||
@ -3436,10 +3442,7 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
|
|||||||
}
|
}
|
||||||
rl = &rl_inter;
|
rl = &rl_inter;
|
||||||
|
|
||||||
if(s->alternate_scan)
|
scan_table = s->intra_scantable.permutated;
|
||||||
scan_table = s->intra_v_scantable.permutated; /* left */
|
|
||||||
else
|
|
||||||
scan_table = s->intra_scantable.permutated;
|
|
||||||
|
|
||||||
if(s->mpeg_quant){
|
if(s->mpeg_quant){
|
||||||
qmul=1;
|
qmul=1;
|
||||||
@ -4093,11 +4096,20 @@ int mpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
|
|
||||||
/* load custom intra matrix */
|
/* load custom intra matrix */
|
||||||
if(get_bits1(&s->gb)){
|
if(get_bits1(&s->gb)){
|
||||||
|
int last=0;
|
||||||
for(i=0; i<64; i++){
|
for(i=0; i<64; i++){
|
||||||
v= get_bits(&s->gb, 8);
|
v= get_bits(&s->gb, 8);
|
||||||
if(v==0) break;
|
if(v==0) break;
|
||||||
|
|
||||||
|
last= v;
|
||||||
|
j= s->idct_permutation[ ff_zigzag_direct[i] ];
|
||||||
|
s->intra_matrix[j]= v;
|
||||||
|
s->chroma_intra_matrix[j]= v;
|
||||||
|
}
|
||||||
|
|
||||||
j= s->intra_scantable.permutated[i];
|
/* replicate last value */
|
||||||
|
for(; i<64; i++){
|
||||||
|
j= s->idct_permutation[ ff_zigzag_direct[i] ];
|
||||||
s->intra_matrix[j]= v;
|
s->intra_matrix[j]= v;
|
||||||
s->chroma_intra_matrix[j]= v;
|
s->chroma_intra_matrix[j]= v;
|
||||||
}
|
}
|
||||||
@ -4105,20 +4117,22 @@ int mpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
|
|
||||||
/* load custom non intra matrix */
|
/* load custom non intra matrix */
|
||||||
if(get_bits1(&s->gb)){
|
if(get_bits1(&s->gb)){
|
||||||
|
int last=0;
|
||||||
for(i=0; i<64; i++){
|
for(i=0; i<64; i++){
|
||||||
v= get_bits(&s->gb, 8);
|
v= get_bits(&s->gb, 8);
|
||||||
if(v==0) break;
|
if(v==0) break;
|
||||||
|
|
||||||
j= s->intra_scantable.permutated[i];
|
last= v;
|
||||||
|
j= s->idct_permutation[ ff_zigzag_direct[i] ];
|
||||||
s->inter_matrix[j]= v;
|
s->inter_matrix[j]= v;
|
||||||
s->chroma_inter_matrix[j]= v;
|
s->chroma_inter_matrix[j]= v;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* replicate last value */
|
/* replicate last value */
|
||||||
for(; i<64; i++){
|
for(; i<64; i++){
|
||||||
j= s->intra_scantable.permutated[i];
|
j= s->idct_permutation[ ff_zigzag_direct[i] ];
|
||||||
s->inter_matrix[j]= v;
|
s->inter_matrix[j]= last;
|
||||||
s->chroma_inter_matrix[j]= v;
|
s->chroma_inter_matrix[j]= last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4321,6 +4335,18 @@ int mpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
s->alternate_scan= 0;
|
s->alternate_scan= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(s->alternate_scan){
|
||||||
|
ff_init_scantable(s, &s->inter_scantable , ff_alternate_vertical_scan);
|
||||||
|
ff_init_scantable(s, &s->intra_scantable , ff_alternate_vertical_scan);
|
||||||
|
ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_vertical_scan);
|
||||||
|
ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan);
|
||||||
|
} else{
|
||||||
|
ff_init_scantable(s, &s->inter_scantable , ff_zigzag_direct);
|
||||||
|
ff_init_scantable(s, &s->intra_scantable , ff_zigzag_direct);
|
||||||
|
ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_horizontal_scan);
|
||||||
|
ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan);
|
||||||
|
}
|
||||||
|
|
||||||
if(s->pict_type == S_TYPE && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
|
if(s->pict_type == S_TYPE && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
|
||||||
if(s->num_sprite_warping_points){
|
if(s->num_sprite_warping_points){
|
||||||
mpeg4_decode_sprite_trajectory(s);
|
mpeg4_decode_sprite_trajectory(s);
|
||||||
|
@ -164,6 +164,11 @@ uint64_t time= rdtsc();
|
|||||||
init_get_bits(&s->gb, buf, buf_size);
|
init_get_bits(&s->gb, buf, buf_size);
|
||||||
s->bitstream_buffer_size=0;
|
s->bitstream_buffer_size=0;
|
||||||
|
|
||||||
|
if (!s->context_initialized) {
|
||||||
|
if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* let's go :-) */
|
/* let's go :-) */
|
||||||
if (s->h263_msmpeg4) {
|
if (s->h263_msmpeg4) {
|
||||||
ret = msmpeg4_decode_picture_header(s);
|
ret = msmpeg4_decode_picture_header(s);
|
||||||
@ -188,7 +193,10 @@ uint64_t time= rdtsc();
|
|||||||
/* and other parameters. So then we could init the picture */
|
/* and other parameters. So then we could init the picture */
|
||||||
/* FIXME: By the way H263 decoder is evolving it should have */
|
/* FIXME: By the way H263 decoder is evolving it should have */
|
||||||
/* an H263EncContext */
|
/* an H263EncContext */
|
||||||
if (s->width != avctx->width || s->height != avctx->height) {
|
if ( s->width != avctx->width || s->height != avctx->height
|
||||||
|
|| avctx->aspect_ratio_info != s->aspect_ratio_info
|
||||||
|
|| avctx->aspected_width != s->aspected_width
|
||||||
|
|| avctx->aspected_height != s->aspected_height) {
|
||||||
/* H.263 could change picture size any time */
|
/* H.263 could change picture size any time */
|
||||||
MPV_common_end(s);
|
MPV_common_end(s);
|
||||||
s->context_initialized=0;
|
s->context_initialized=0;
|
||||||
|
@ -1435,7 +1435,7 @@ static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
|
|||||||
if (get_bits1(&s->gb)) {
|
if (get_bits1(&s->gb)) {
|
||||||
for(i=0;i<64;i++) {
|
for(i=0;i<64;i++) {
|
||||||
v = get_bits(&s->gb, 8);
|
v = get_bits(&s->gb, 8);
|
||||||
j = s->intra_scantable.permutated[i];
|
j= s->idct_permutation[ ff_zigzag_direct[i] ];
|
||||||
s->intra_matrix[j] = v;
|
s->intra_matrix[j] = v;
|
||||||
s->chroma_intra_matrix[j] = v;
|
s->chroma_intra_matrix[j] = v;
|
||||||
}
|
}
|
||||||
@ -1443,7 +1443,7 @@ static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
|
|||||||
if (get_bits1(&s->gb)) {
|
if (get_bits1(&s->gb)) {
|
||||||
for(i=0;i<64;i++) {
|
for(i=0;i<64;i++) {
|
||||||
v = get_bits(&s->gb, 8);
|
v = get_bits(&s->gb, 8);
|
||||||
j = s->intra_scantable.permutated[i];
|
j= s->idct_permutation[ ff_zigzag_direct[i] ];
|
||||||
s->inter_matrix[j] = v;
|
s->inter_matrix[j] = v;
|
||||||
s->chroma_inter_matrix[j] = v;
|
s->chroma_inter_matrix[j] = v;
|
||||||
}
|
}
|
||||||
@ -1451,14 +1451,14 @@ static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
|
|||||||
if (get_bits1(&s->gb)) {
|
if (get_bits1(&s->gb)) {
|
||||||
for(i=0;i<64;i++) {
|
for(i=0;i<64;i++) {
|
||||||
v = get_bits(&s->gb, 8);
|
v = get_bits(&s->gb, 8);
|
||||||
j = s->intra_scantable.permutated[i];
|
j= s->idct_permutation[ ff_zigzag_direct[i] ];
|
||||||
s->chroma_intra_matrix[j] = v;
|
s->chroma_intra_matrix[j] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (get_bits1(&s->gb)) {
|
if (get_bits1(&s->gb)) {
|
||||||
for(i=0;i<64;i++) {
|
for(i=0;i<64;i++) {
|
||||||
v = get_bits(&s->gb, 8);
|
v = get_bits(&s->gb, 8);
|
||||||
j = s->intra_scantable.permutated[i];
|
j= s->idct_permutation[ ff_zigzag_direct[i] ];
|
||||||
s->chroma_inter_matrix[j] = v;
|
s->chroma_inter_matrix[j] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user