mirror of
https://git.videolan.org/git/ffmpeg.git
synced 2024-09-06 08:08:58 +02:00
Factorize quantization matrix loading code out.
Originally committed as revision 18723 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
da00b52578
commit
45ccc61a06
@ -1470,42 +1470,31 @@ static void mpeg_decode_picture_display_extension(Mpeg1Context *s1)
|
||||
);
|
||||
}
|
||||
|
||||
static int load_matrix(MpegEncContext *s, uint16_t matrix0[64], uint16_t matrix1[64], int intra){
|
||||
int i;
|
||||
|
||||
for(i=0; i<64; i++) {
|
||||
int j = s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
|
||||
int v = get_bits(&s->gb, 8);
|
||||
if(v==0){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "matrix damaged\n");
|
||||
return -1;
|
||||
}
|
||||
matrix0[j] = v;
|
||||
if(matrix1)
|
||||
matrix1[j] = v;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
|
||||
{
|
||||
int i, v, j;
|
||||
|
||||
dprintf(s->avctx, "matrix extension\n");
|
||||
|
||||
if (get_bits1(&s->gb)) {
|
||||
for(i=0;i<64;i++) {
|
||||
v = get_bits(&s->gb, 8);
|
||||
j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
|
||||
s->intra_matrix[j] = v;
|
||||
s->chroma_intra_matrix[j] = v;
|
||||
}
|
||||
}
|
||||
if (get_bits1(&s->gb)) {
|
||||
for(i=0;i<64;i++) {
|
||||
v = get_bits(&s->gb, 8);
|
||||
j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
|
||||
s->inter_matrix[j] = v;
|
||||
s->chroma_inter_matrix[j] = v;
|
||||
}
|
||||
}
|
||||
if (get_bits1(&s->gb)) {
|
||||
for(i=0;i<64;i++) {
|
||||
v = get_bits(&s->gb, 8);
|
||||
j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
|
||||
s->chroma_intra_matrix[j] = v;
|
||||
}
|
||||
}
|
||||
if (get_bits1(&s->gb)) {
|
||||
for(i=0;i<64;i++) {
|
||||
v = get_bits(&s->gb, 8);
|
||||
j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
|
||||
s->chroma_inter_matrix[j] = v;
|
||||
}
|
||||
}
|
||||
if(get_bits1(&s->gb)) load_matrix(s, s->chroma_intra_matrix, s->intra_matrix, 1);
|
||||
if(get_bits1(&s->gb)) load_matrix(s, s->chroma_inter_matrix, s->inter_matrix, 0);
|
||||
if(get_bits1(&s->gb)) load_matrix(s, s->chroma_intra_matrix, NULL , 1);
|
||||
if(get_bits1(&s->gb)) load_matrix(s, s->chroma_inter_matrix, NULL , 0);
|
||||
}
|
||||
|
||||
static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
|
||||
@ -2008,22 +1997,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
|
||||
|
||||
/* get matrix */
|
||||
if (get_bits1(&s->gb)) {
|
||||
for(i=0;i<64;i++) {
|
||||
v = get_bits(&s->gb, 8);
|
||||
if(v==0){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "intra matrix damaged\n");
|
||||
return -1;
|
||||
}
|
||||
j = s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
|
||||
s->intra_matrix[j] = v;
|
||||
s->chroma_intra_matrix[j] = v;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
dprintf(s->avctx, "intra matrix present\n");
|
||||
for(i=0;i<64;i++)
|
||||
dprintf(s->avctx, " %d", s->intra_matrix[s->dsp.idct_permutation[i]]);
|
||||
dprintf(s->avctx, "\n");
|
||||
#endif
|
||||
load_matrix(s, s->chroma_intra_matrix, s->intra_matrix, 1);
|
||||
} else {
|
||||
for(i=0;i<64;i++) {
|
||||
j = s->dsp.idct_permutation[i];
|
||||
@ -2033,22 +2007,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
|
||||
}
|
||||
}
|
||||
if (get_bits1(&s->gb)) {
|
||||
for(i=0;i<64;i++) {
|
||||
v = get_bits(&s->gb, 8);
|
||||
if(v==0){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "inter matrix damaged\n");
|
||||
return -1;
|
||||
}
|
||||
j = s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
|
||||
s->inter_matrix[j] = v;
|
||||
s->chroma_inter_matrix[j] = v;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
dprintf(s->avctx, "non-intra matrix present\n");
|
||||
for(i=0;i<64;i++)
|
||||
dprintf(s->avctx, " %d", s->inter_matrix[s->dsp.idct_permutation[i]]);
|
||||
dprintf(s->avctx, "\n");
|
||||
#endif
|
||||
load_matrix(s, s->chroma_inter_matrix, s->inter_matrix, 0);
|
||||
} else {
|
||||
for(i=0;i<64;i++) {
|
||||
int j= s->dsp.idct_permutation[i];
|
||||
|
Loading…
Reference in New Issue
Block a user