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

conrad subversion at mplayerhq.hu
Wed Dec 3 22:28:33 CET 2008


Author: conrad
Date: Wed Dec  3 22:28:33 2008
New Revision: 3844

Log:
Move luma|chroma excursion|offset to a separate struct


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

Modified: dirac/libavcodec/dirac.c
==============================================================================
--- dirac/libavcodec/dirac.c	(original)
+++ dirac/libavcodec/dirac.c	Wed Dec  3 22:28:33 2008
@@ -81,10 +81,12 @@ static const AVRational dirac_frame_rate
     {25, 2},
 };
 
-static const uint16_t dirac_preset_luma_offset[]      = { 0,   16,  64,  256  };
-static const uint16_t dirac_preset_luma_excursion[]   = { 255, 219, 876, 3504 };
-static const uint16_t dirac_preset_chroma_offset[]    = { 128, 128, 512, 2048 };
-static const uint16_t dirac_preset_chroma_excursion[] = { 255, 224, 896, 3584 };
+static const dirac_pixel_range dirac_pixel_range_presets[] = {
+    { 0,   255,  128,  255  },
+    { 16,  219,  128,  224  },
+    { 64,  876,  512,  896  },
+    { 256, 3504, 2048, 3584 },
+};
 
 static const color_specification dirac_color_spec_presets[] = {
     { COLOR_PRIMARY_HDTV,     COLOR_MATRIX_HDTV, TRANSFER_FUNC_TV },
@@ -251,24 +253,21 @@ static int parse_source_parameters(GetBi
 
     /* Override signal range. */
     if (get_bits1(gb)) {
-        source->signal_range_index = svq3_get_ue_golomb(gb);
+        source->pixel_range_index = svq3_get_ue_golomb(gb);
 
-        if (source->signal_range_index > 4)
+        if (source->pixel_range_index > 4)
             return -1;
 
-        if (!source->signal_range_index) {
-            source->luma_offset      = svq3_get_ue_golomb(gb);
-            source->luma_excursion   = svq3_get_ue_golomb(gb);
-            source->chroma_offset    = svq3_get_ue_golomb(gb);
-            source->chroma_excursion = svq3_get_ue_golomb(gb);
+        if (!source->pixel_range_index) {
+            source->pixel_range.luma_offset      = svq3_get_ue_golomb(gb);
+            source->pixel_range.luma_excursion   = svq3_get_ue_golomb(gb);
+            source->pixel_range.chroma_offset    = svq3_get_ue_golomb(gb);
+            source->pixel_range.chroma_excursion = svq3_get_ue_golomb(gb);
         }
     }
-    if (source->signal_range_index > 0) {
-        int idx = source->signal_range_index - 1;
-        source->luma_offset      = dirac_preset_luma_offset     [idx];
-        source->luma_excursion   = dirac_preset_luma_excursion  [idx];
-        source->chroma_offset    = dirac_preset_chroma_offset   [idx];
-        source->chroma_excursion = dirac_preset_chroma_excursion[idx];
+    if (source->pixel_range_index > 0) {
+        source->pixel_range =
+                dirac_pixel_range_presets[source->pixel_range_index-1];
     }
 
     /* color spec */
@@ -300,8 +299,8 @@ static int parse_source_parameters(GetBi
     source->k_r = dirac_preset_kr[source->color_spec_index];
     source->k_b = dirac_preset_kb[source->color_spec_index];
 
-    luma_depth   = av_log2(source->luma_excursion   + 1);
-    chroma_depth = av_log2(source->chroma_excursion + 1);
+    luma_depth   = av_log2(source->pixel_range.luma_excursion   + 1);
+    chroma_depth = av_log2(source->pixel_range.chroma_excursion + 1);
     if (luma_depth > 8 || chroma_depth > 8)
         av_log(avctx, AV_LOG_WARNING, "Bitdepth greater than 8, may not work");
 

Modified: dirac/libavcodec/dirac.h
==============================================================================
--- dirac/libavcodec/dirac.h	(original)
+++ dirac/libavcodec/dirac.h	Wed Dec  3 22:28:33 2008
@@ -60,6 +60,13 @@ typedef struct {
     dirac_transfer_func transfer_function;
 } color_specification;
 
+typedef struct {
+    uint16_t luma_offset;
+    uint16_t luma_excursion;
+    uint16_t chroma_offset;
+    uint16_t chroma_excursion;
+} dirac_pixel_range;
+
 #define DIRAC_SIGN(x) ((x) > 0 ? 2 : ((x) < 0 ? 1 : 0))
 #define DIRAC_PARSE_INFO_PREFIX 0x42424344
 #define CALC_PADDING(size, depth) \
@@ -86,15 +93,10 @@ typedef struct {
     uint16_t clean_left_offset;
     uint16_t clean_right_offset;
 
-    uint8_t signal_range_index;        ///< index into dirac_signal_range[]
+    uint8_t pixel_range_index;        ///< index into dirac_pixel_range_presets[]
     uint8_t color_spec_index;          ///< index into dirac_color_spec_presets[]
 
-    /* luma and chroma offsets */
-    uint16_t luma_offset;
-    uint16_t luma_excursion;
-    uint16_t chroma_offset;
-    uint16_t chroma_excursion;
-
+    dirac_pixel_range pixel_range;
     color_specification color_spec;
     float k_r;
     float k_b; /* XXX: ??? */



More information about the FFmpeg-soc mailing list