[FFmpeg-cvslog] r18723 - trunk/libavcodec/mpeg12.c
michael
subversion
Fri May 1 14:17:25 CEST 2009
Author: michael
Date: Fri May 1 14:17:25 2009
New Revision: 18723
Log:
Factorize quantization matrix loading code out.
Modified:
trunk/libavcodec/mpeg12.c
Modified: trunk/libavcodec/mpeg12.c
==============================================================================
--- trunk/libavcodec/mpeg12.c Thu Apr 30 23:34:56 2009 (r18722)
+++ trunk/libavcodec/mpeg12.c Fri May 1 14:17:25 2009 (r18723)
@@ -1470,42 +1470,31 @@ static void mpeg_decode_picture_display_
);
}
+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(AVCodec
/* 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(AVCodec
}
}
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];
More information about the ffmpeg-cvslog
mailing list