[FFmpeg-soc] [soc]: r3900 - in dirac/libavcodec: dirac.c dirac.h diracdec.c
conrad
subversion at mplayerhq.hu
Thu Jan 1 21:31:04 CET 2009
Author: conrad
Date: Thu Jan 1 21:31:03 2009
New Revision: 3900
Log:
Parse low-delay syntax quantization matrices
Modified:
dirac/libavcodec/dirac.c
dirac/libavcodec/dirac.h
dirac/libavcodec/diracdec.c
Modified: dirac/libavcodec/dirac.c
==============================================================================
--- dirac/libavcodec/dirac.c Sun Dec 28 08:38:00 2008 (r3899)
+++ dirac/libavcodec/dirac.c Thu Jan 1 21:31:03 2009 (r3900)
@@ -127,6 +127,16 @@ static const uint8_t eighthpel_weights[]
{ 1, 3, 3, 9 }, /* rx=3, ry=3 */
};
+uint8_t ff_dirac_default_qmat[][4][4] = {
+ { { 5, 3, 3, 0}, { 0, 4, 4, 1}, { 0, 5, 5, 2}, { 0, 6, 6, 3} },
+ { { 4, 2, 2, 0}, { 0, 4, 4, 2}, { 0, 5, 5, 3}, { 0, 7, 7, 5} },
+ { { 5, 3, 3, 0}, { 0, 4, 4, 1}, { 0, 5, 5, 2}, { 0, 6, 6, 3} },
+ { { 8, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0} },
+ { { 8, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0} },
+ { { 0, 4, 4, 8}, { 0, 8, 8, 12}, { 0, 13, 13, 17}, { 0, 17, 17, 21} },
+ { { 3, 1, 1, 0}, { 0, 4, 4, 2}, { 0, 6, 6, 5}, { 0, 9, 9, 7} },
+};
+
/**
* Parse the source parameters in the sequence header.
*/
Modified: dirac/libavcodec/dirac.h
==============================================================================
--- dirac/libavcodec/dirac.h Sun Dec 28 08:38:00 2008 (r3899)
+++ dirac/libavcodec/dirac.h Thu Jan 1 21:31:03 2009 (r3900)
@@ -187,6 +187,12 @@ typedef struct DiracContext {
unsigned int codeblocksh[MAX_DECOMPOSITIONS+1];
unsigned int codeblocksv[MAX_DECOMPOSITIONS+1];
+ int low_delay; ///< use the low delay syntax
+ unsigned int x_slices;
+ unsigned int y_slices;
+ AVRational slice_bytes;
+ uint8_t quant_matrix[MAX_DECOMPOSITIONS][4];
+
int chroma_hshift; ///< horizontal bits to shift for choma
int chroma_vshift; ///< vertical bits to shift for choma
@@ -508,4 +514,6 @@ void dirac_dump_source_parameters(AVCode
int ff_dirac_parse_sequence_header(GetBitContext *gb, AVCodecContext *avctx,
dirac_source_params *source);
+extern uint8_t ff_dirac_default_qmat[][4][4];
+
#endif /* AVCODEC_DIRAC_H */
Modified: dirac/libavcodec/diracdec.c
==============================================================================
--- dirac/libavcodec/diracdec.c Sun Dec 28 08:38:00 2008 (r3899)
+++ dirac/libavcodec/diracdec.c Thu Jan 1 21:31:03 2009 (r3900)
@@ -775,7 +775,7 @@ static int dirac_decode_frame_internal(D
static int parse_frame(DiracContext *s)
{
int retire, picnum;
- int i;
+ int i, level;
GetBitContext *gb = &s->gb;
picnum= s->current_picture->display_picture_number = get_bits_long(gb, 32);
@@ -831,6 +831,7 @@ static int parse_frame(DiracContext *s)
s->decoding.wavelet_depth = svq3_get_ue_golomb(gb);
+ if (!s->low_delay) {
/* Codeblock paramaters (core syntax only) */
if (get_bits1(gb)) {
for (i = 0; i <= s->decoding.wavelet_depth; i++) {
@@ -842,6 +843,34 @@ static int parse_frame(DiracContext *s)
} else
for (i = 0; i <= s->decoding.wavelet_depth; i++)
s->codeblocksh[i] = s->codeblocksv[i] = 1;
+ } else {
+ s->x_slices = svq3_get_ue_golomb(gb);
+ s->y_slices = svq3_get_ue_golomb(gb);
+ s->slice_bytes.num = svq3_get_ue_golomb(gb);
+ s->slice_bytes.den = svq3_get_ue_golomb(gb);
+
+ if (get_bits1(gb)) {
+ // custom quantization matrix
+ s->quant_matrix[0][0] = svq3_get_ue_golomb(gb);
+ for (level = 0; level < s->decoding.wavelet_depth; level++) {
+ s->quant_matrix[level][1] = svq3_get_ue_golomb(gb);
+ s->quant_matrix[level][2] = svq3_get_ue_golomb(gb);
+ s->quant_matrix[level][3] = svq3_get_ue_golomb(gb);
+ }
+ } else {
+ // default quantization matrix
+ for (level = 0; level < s->decoding.wavelet_depth; level++)
+ for (i = 0; i < 4; i++) {
+ s->quant_matrix[level][i] =
+ ff_dirac_default_qmat[s->wavelet_idx][level][i];
+
+ // haar with no shift differs for different depths
+ if (s->wavelet_idx == 3)
+ s->quant_matrix[level][i] +=
+ 4*(s->decoding.wavelet_depth-1 - level);
+ }
+ }
+ }
}
return 0;
}
@@ -866,6 +895,7 @@ static int alloc_frame(AVCodecContext *a
s->refs = parse_code & 0x03;
s->is_arith = (parse_code & 0x48) == 0x08;
+ s->low_delay = (parse_code & 0x88) == 0x88;
pic->reference = (parse_code & 0x0C) == 0x0C;
pic->key_frame = s->refs == 0;
pic->pict_type = pict_type[s->refs];
More information about the FFmpeg-soc
mailing list