[FFmpeg-soc] [soc]: r3775 - in dirac/libavcodec: dirac.c dirac.h diracdec.c

conrad subversion at mplayerhq.hu
Mon Nov 10 04:11:20 CET 2008


Author: conrad
Date: Mon Nov 10 04:11:19 2008
New Revision: 3775

Log:
Update the picture header parsing to the latest spec


Modified:
   dirac/libavcodec/dirac.c
   dirac/libavcodec/dirac.h
   dirac/libavcodec/diracdec.c

Modified: dirac/libavcodec/dirac.c
==============================================================================
--- dirac/libavcodec/dirac.c	(original)
+++ dirac/libavcodec/dirac.c	Mon Nov 10 04:11:19 2008
@@ -64,25 +64,6 @@ const struct source_parameters dirac_sou
     { 7680, 4320, 1, 0, 1, 6,  1, 3840, 2160, 0, 0, 3, 3 },
 };
 
-/* Defaults for decoding parameters.  */
-const struct decoding_parameters dirac_decoding_parameters_defaults[13] =
-{
-    { 4, 0, 1, 8,  12, 8,  12, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 32, 32, 512  },
-    { 4, 0, 1, 4,   8, 4,   8, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 16, 16, 512  },
-    { 4, 0, 1, 4,   8, 4,   8, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 16, 16, 512  },
-    { 4, 0, 1, 8,  12, 8,  12, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 32, 32, 512  },
-    { 4, 0, 1, 8,  12, 8,  12, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 32, 32, 512  },
-    { 4, 0, 1, 8,  12, 8,  12, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 32, 32, 512  },
-    { 4, 0, 1, 8,  12, 8,  12, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 32, 32, 512  },
-
-    { 4, 0, 1, 8,  12, 8,  12, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 32, 32, 512  },
-    { 4, 0, 1, 8,  12, 8,  12, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 32, 32, 512  },
-    { 4, 0, 1, 12, 16, 12, 16, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 48, 48, 768  },
-    { 4, 0, 1, 16, 24, 16, 24, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 48, 48, 1024 },
-    { 4, 6, 1, 16, 24, 16, 24, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 48, 48, 1024 },
-    { 4, 6, 0, 16, 24, 16, 24, 2, 1, 1, 1, 1, 1, 4, 3, 1, 1, 8, 6, 12, 8, 48, 48, 1024 }
-};
-
 const AVRational dirac_preset_aspect_ratios[] =
 {
     {1, 1}, {10, 11}, {12, 11},

Modified: dirac/libavcodec/dirac.h
==============================================================================
--- dirac/libavcodec/dirac.h	(original)
+++ dirac/libavcodec/dirac.h	Mon Nov 10 04:11:19 2008
@@ -113,8 +113,6 @@ struct source_parameters
 struct decoding_parameters
 {
     uint8_t wavelet_depth;          ///< depth of the IDWT
-    uint8_t wavelet_idx_intra;      ///< wavelet transform for intra frames
-    uint8_t wavelet_idx_inter;      ///< wavelet transform for inter frames
 
     uint8_t luma_xbsep;
     uint8_t luma_xblen;
@@ -127,18 +125,6 @@ struct decoding_parameters
     int16_t picture_weight_ref2;
     unsigned int picture_weight_precision;
 
-    /* Codeblocks h*v.  */
-    int intra_hlevel_012, intra_vlevel_012;
-    int intra_hlevel_other, intra_vlevel_other;
-    int inter_hlevel_01, inter_vlevel_01;
-    int inter_hlevel_2, inter_vlevel_2;
-    int inter_hlevel_other, inter_vlevel_other;
-
-    int slice_width;
-    int slide_height;
-    int slice_bits;
-
-    /* Calculated.  */
     uint8_t chroma_xbsep;
     uint8_t chroma_xblen;
     uint8_t chroma_ybsep;
@@ -146,9 +132,9 @@ struct decoding_parameters
 };
 
 struct globalmc_parameters {
-    unsigned int b[2];                          ///< b vector
-    unsigned int A[2][2];                       ///< A matrix
-    int c[2];                                   ///< c vector
+    unsigned int pan_tilt[2];                   ///< pan/tilt vector
+    unsigned int zrs[2][2];                     ///< zoom/rotate/shear matrix
+    int perspective[2];                         ///< perspective vector
     unsigned int zrs_exp;
     unsigned int perspective_exp;
 };
@@ -220,6 +206,7 @@ typedef struct DiracContext {
 
     struct decoding_parameters frame_decoding;
 
+    unsigned int codeblock_mode;
     unsigned int codeblocksh[7]; /* XXX: 7 levels.  */
     unsigned int codeblocksv[7]; /* XXX: 7 levels.  */
 

Modified: dirac/libavcodec/diracdec.c
==============================================================================
--- dirac/libavcodec/diracdec.c	(original)
+++ dirac/libavcodec/diracdec.c	Mon Nov 10 04:11:19 2008
@@ -230,9 +230,6 @@ static int parse_sequence_header(DiracCo
 
     picture_coding_mode = svq3_get_ue_golomb(gb);
 
-    /* Fill in defaults for the decoding parameters.  */
-    s->decoding = dirac_decoding_parameters_defaults[video_format];
-
     return 0;
 }
 
@@ -449,7 +446,7 @@ static int dirac_unpack_prediction_param
     /* Read block parameters.  */
     unsigned int idx = svq3_get_ue_golomb(gb);
 
-    if (idx > 3)
+    if (idx > 4)
         return -1;
 
     if (idx == 0) {
@@ -487,24 +484,27 @@ static int dirac_unpack_prediction_param
 
             /* Pan/til parameters.  */
             if (get_bits1(gb)) {
-                s->globalmc.b[0] = dirac_get_se_golomb(gb);
-                s->globalmc.b[1] = dirac_get_se_golomb(gb);
+                s->globalmc.pan_tilt[0] = dirac_get_se_golomb(gb);
+                s->globalmc.pan_tilt[1] = dirac_get_se_golomb(gb);
             }
 
             /* Rotation/shear parameters.  */
             if (get_bits1(gb)) {
                 s->globalmc.zrs_exp = svq3_get_ue_golomb(gb);
-                s->globalmc.A[0][0] = dirac_get_se_golomb(gb);
-                s->globalmc.A[0][1] = dirac_get_se_golomb(gb);
-                s->globalmc.A[1][0] = dirac_get_se_golomb(gb);
-                s->globalmc.A[1][1] = dirac_get_se_golomb(gb);
+                s->globalmc.zrs[0][0] = dirac_get_se_golomb(gb);
+                s->globalmc.zrs[0][1] = dirac_get_se_golomb(gb);
+                s->globalmc.zrs[1][0] = dirac_get_se_golomb(gb);
+                s->globalmc.zrs[1][1] = dirac_get_se_golomb(gb);
+            } else {
+                s->globalmc.zrs[0][0] = 1;
+                s->globalmc.zrs[1][1] = 1;
             }
 
             /* Perspective parameters.  */
             if (get_bits1(gb)) {
                 s->globalmc.perspective_exp = svq3_get_ue_golomb(gb);
-                s->globalmc.c[0]            = dirac_get_se_golomb(gb);
-                s->globalmc.c[1]            = dirac_get_se_golomb(gb);
+                s->globalmc.perspective[0] = dirac_get_se_golomb(gb);
+                s->globalmc.perspective[1] = dirac_get_se_golomb(gb);
             }
         }
     }
@@ -513,16 +513,10 @@ static int dirac_unpack_prediction_param
        just ignore it, it should and will be zero.  */
     svq3_get_ue_golomb(gb);
 
-    /* XXX: For now set the weights here, I can't find this in the
-       specification.  */
-    s->frame_decoding.picture_weight_ref1 = 1;
-    if (s->refs == 2) {
-        s->frame_decoding.picture_weight_precision = 1;
-        s->frame_decoding.picture_weight_ref2      = 1;
-    } else {
-        s->frame_decoding.picture_weight_precision = 0;
-        s->frame_decoding.picture_weight_ref2      = 0;
-    }
+    /* Default weights */
+    s->frame_decoding.picture_weight_precision = 1;
+    s->frame_decoding.picture_weight_ref1      = 1;
+    s->frame_decoding.picture_weight_ref2      = 1;
 
     /* Override reference picture weights.  */
     if (get_bits1(gb)) {
@@ -683,14 +677,14 @@ static int dirac_unpack_prediction_data(
 
     s->sbsplit  = av_mallocz(s->sbwidth * s->sbheight * sizeof(int));
     if (!s->sbsplit) {
-        av_log(s->avctx, AV_LOG_ERROR, "avcodec_check_dimensions() failed\n");
+        av_log(s->avctx, AV_LOG_ERROR, "av_mallocz() failed\n");
         return -1;
     }
 
     s->blmotion = av_mallocz(s->blwidth * s->blheight * sizeof(*s->blmotion));
     if (!s->blmotion) {
         av_freep(&s->sbsplit);
-        av_log(s->avctx, AV_LOG_ERROR, "avcodec_check_dimensions() failed\n");
+        av_log(s->avctx, AV_LOG_ERROR, "av_mallocz() failed\n");
         return -1;
     }
 
@@ -995,24 +989,22 @@ static int parse_frame(DiracContext *s)
     if (!s->zero_res) {
         s->wavelet_idx = svq3_get_ue_golomb(gb);
 
-        if (s->wavelet_idx > 7)
+        if (s->wavelet_idx > 6)
             return -1;
 
         s->frame_decoding.wavelet_depth = svq3_get_ue_golomb(gb);
 
-        /* Spatial partitioning.  */
+        /* Codeblock paramaters (core syntax only) */
         if (get_bits1(gb)) {
-            unsigned int idx;
-
             for (i = 0; i <= s->frame_decoding.wavelet_depth; i++) {
                 s->codeblocksh[i] = svq3_get_ue_golomb(gb);
                 s->codeblocksv[i] = svq3_get_ue_golomb(gb);
             }
 
-            idx = svq3_get_ue_golomb(gb);
-            dprintf(s->avctx, "Codeblock mode idx: %d\n", idx);
-            /* XXX: Here 0, so single quant.  */
-        }
+            s->codeblock_mode = svq3_get_ue_golomb(gb);
+        } else
+            for (i = 0; i <= s->frame_decoding.wavelet_depth; i++)
+                s->codeblocksh[i] = s->codeblocksv[i] = 1;
     }
 
 #define CALC_PADDING(size, depth) \



More information about the FFmpeg-soc mailing list