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

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


Author: conrad
Date: Mon Nov 10 04:12:11 2008
New Revision: 3798

Log:
Move parse_sequence_headers to dirac.c


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:12:11 2008
@@ -171,6 +171,194 @@ void dirac_dump_source_parameters(AVCode
     dprintf(avctx, "-----------------------------------------------------\n");
 }
 
+/**
+ * Parse the source parameters in the access unit header
+ */
+static int parse_source_parameters(DiracContext *s)
+{
+    GetBitContext *gb = &s->gb;
+
+    /* Override the luma dimensions.  */
+    if (get_bits1(gb)) {
+        s->source.luma_width  = svq3_get_ue_golomb(gb);
+        s->source.luma_height = svq3_get_ue_golomb(gb);
+    }
+
+    /* Override the chroma format.  */
+    if (get_bits1(gb))
+        s->source.chroma_format = svq3_get_ue_golomb(gb);
+
+    /* Calculate the chroma dimensions.  */
+    s->chroma_hshift = s->source.chroma_format > 0;
+    s->chroma_vshift = s->source.chroma_format > 1;
+    s->source.chroma_width  = s->source.luma_width  >> s->chroma_hshift;
+    s->source.chroma_height = s->source.luma_height >> s->chroma_vshift;
+
+    if (get_bits1(gb))
+        /* Interlace.  */
+        s->source.interlaced = svq3_get_ue_golomb(gb);
+    if (s->source.interlaced > 1)
+        return -1;
+
+    /* Framerate.  */
+    if (get_bits1(gb)) {
+        s->source.frame_rate_index = svq3_get_ue_golomb(gb);
+
+        if (s->source.frame_rate_index > 10)
+            return -1;
+
+        if (! s->source.frame_rate_index) {
+            s->source.frame_rate.num = svq3_get_ue_golomb(gb);
+            s->source.frame_rate.den = svq3_get_ue_golomb(gb);
+        }
+    }
+    if (s->source.frame_rate_index > 0 && s->source.frame_rate_index <= 10) {
+        if (s->source.frame_rate_index <= 8)
+            s->source.frame_rate = ff_frame_rate_tab[s->source.frame_rate_index];
+        else
+            s->source.frame_rate = ff_dirac_frame_rate[s->source.frame_rate_index-9];
+    }
+
+    /* Override aspect ratio.  */
+    if (get_bits1(gb)) {
+        s->source.aspect_ratio_index = svq3_get_ue_golomb(gb);
+
+        if (s->source.aspect_ratio_index > 6)
+            return -1;
+
+        if (! s->source.aspect_ratio_index) {
+            s->source.aspect_ratio.num = svq3_get_ue_golomb(gb);
+            s->source.aspect_ratio.den = svq3_get_ue_golomb(gb);
+        }
+    }
+    if (s->source.aspect_ratio_index > 0 && s->source.aspect_ratio_index <= 6)
+        s->source.aspect_ratio =
+                ff_dirac_preset_aspect_ratios[s->source.aspect_ratio_index-1];
+
+    /* Override clean area.  */
+    if (get_bits1(gb)) {
+        s->source.clean_width        = svq3_get_ue_golomb(gb);
+        s->source.clean_height       = svq3_get_ue_golomb(gb);
+        s->source.clean_left_offset  = svq3_get_ue_golomb(gb);
+        s->source.clean_right_offset = svq3_get_ue_golomb(gb);
+    }
+
+    /* Override signal range.  */
+    if (get_bits1(gb)) {
+        s->source.signal_range_index = svq3_get_ue_golomb(gb);
+
+        if (s->source.signal_range_index > 4)
+            return -1;
+
+        if (! s->source.signal_range_index) {
+            s->source.luma_offset      = svq3_get_ue_golomb(gb);
+            s->source.luma_excursion   = svq3_get_ue_golomb(gb);
+            s->source.chroma_offset    = svq3_get_ue_golomb(gb);
+            s->source.chroma_excursion = svq3_get_ue_golomb(gb);
+        }
+    }
+    if (s->source.signal_range_index > 0 && s->source.signal_range_index <= 4) {
+        int idx = s->source.signal_range_index - 1;
+        s->source.luma_offset      = ff_dirac_preset_luma_offset     [idx];
+        s->source.luma_excursion   = ff_dirac_preset_luma_excursion  [idx];
+        s->source.chroma_offset    = ff_dirac_preset_chroma_offset   [idx];
+        s->source.chroma_excursion = ff_dirac_preset_chroma_excursion[idx];
+    }
+
+    /* Color spec.  */
+    s->source.color_spec = ff_dirac_color_spec_presets[s->source.color_spec_index];
+    if (get_bits1(gb)) {
+        s->source.color_spec_index = svq3_get_ue_golomb(gb);
+
+        if (s->source.color_spec_index > 4)
+            return -1;
+
+        s->source.color_spec = ff_dirac_color_spec_presets[s->source.color_spec_index];
+
+        if (! s->source.color_spec_index) {
+            /* Color primaries.  */
+            if (get_bits1(gb)) {
+                unsigned int primaries_idx = svq3_get_ue_golomb(gb);
+
+                if (primaries_idx > 3)
+                    return -1;
+
+                s->source.color_spec.primaries = primaries_idx;
+            }
+
+            /* Override matrix.  */
+            if (get_bits1(gb)) {
+                unsigned int matrix_idx = svq3_get_ue_golomb(gb);
+
+                if (matrix_idx > 2)
+                    return -1;
+
+                s->source.color_spec.matrix = matrix_idx;
+            }
+
+            /* Transfer function.  */
+            if (get_bits1(gb)) {
+                unsigned int tf_idx = svq3_get_ue_golomb(gb);
+
+                if (tf_idx > 3)
+                    return -1;
+
+                s->source.color_spec.transfer_function = tf_idx;
+            }
+        }
+    }
+    s->source.k_r = ff_dirac_preset_kr[s->source.color_spec_index];
+    s->source.k_b = ff_dirac_preset_kb[s->source.color_spec_index];
+
+    s->source.luma_depth   = av_log2(s->source.luma_excursion   + 1);
+    s->source.chroma_depth = av_log2(s->source.chroma_excursion + 1);
+
+    return 0;
+}
+
+/**
+ * Parse the sequence header
+ */
+int ff_dirac_parse_sequence_header(DiracContext *s)
+{
+    GetBitContext *gb = &s->gb;
+    unsigned int version_major;
+    unsigned int version_minor;
+    unsigned int video_format;
+    unsigned int picture_coding_mode;
+
+    /* Parse parameters.  */
+    version_major = svq3_get_ue_golomb(gb);
+    version_minor = svq3_get_ue_golomb(gb);
+    /* XXX: Don't check the version yet, existing encoders do not yet
+       set this to a sane value (0.6 at the moment).  */
+
+    /* XXX: Not yet documented in the spec.  This is actually the main
+       thing that is missing.  */
+    s->profile = svq3_get_ue_golomb(gb);
+    s->level = svq3_get_ue_golomb(gb);
+    dprintf(s->avctx, "Access unit header: Version %d.%d\n",
+            version_major, version_minor);
+    dprintf(s->avctx, "Profile: %d, Level: %d\n", s->profile, s->level);
+
+    video_format = svq3_get_ue_golomb(gb);
+    dprintf(s->avctx, "Video format: %d\n", video_format);
+
+    if (video_format > 20)
+        return -1;
+
+    /* Fill in defaults for the source parameters.  */
+    s->source = ff_dirac_source_parameters_defaults[video_format];
+
+    /* Override the defaults.  */
+    if (parse_source_parameters(s))
+        return -1;
+
+    picture_coding_mode = svq3_get_ue_golomb(gb);
+
+    return 0;
+}
+
 struct dirac_arith_context_set ff_dirac_context_set_split =
     {
         .follow = { ARITH_CONTEXT_SB_F1, ARITH_CONTEXT_SB_F2,

Modified: dirac/libavcodec/dirac.h
==============================================================================
--- dirac/libavcodec/dirac.h	(original)
+++ dirac/libavcodec/dirac.h	Mon Nov 10 04:12:11 2008
@@ -590,4 +590,6 @@ int dirac_decode_frame(AVCodecContext *a
 
 void dirac_dump_source_parameters(AVCodecContext *avctx);
 
+int ff_dirac_parse_sequence_header(DiracContext *s);
+
 #endif /* AVCODEC_DIRAC_H */

Modified: dirac/libavcodec/diracdec.c
==============================================================================
--- dirac/libavcodec/diracdec.c	(original)
+++ dirac/libavcodec/diracdec.c	Mon Nov 10 04:12:11 2008
@@ -51,194 +51,6 @@ static int decode_end(AVCodecContext *av
 }
 
 /**
- * Parse the source parameters in the access unit header
- */
-static int parse_source_parameters(DiracContext *s)
-{
-    GetBitContext *gb = &s->gb;
-
-    /* Override the luma dimensions.  */
-    if (get_bits1(gb)) {
-        s->source.luma_width  = svq3_get_ue_golomb(gb);
-        s->source.luma_height = svq3_get_ue_golomb(gb);
-    }
-
-    /* Override the chroma format.  */
-    if (get_bits1(gb))
-        s->source.chroma_format = svq3_get_ue_golomb(gb);
-
-    /* Calculate the chroma dimensions.  */
-    s->chroma_hshift = s->source.chroma_format > 0;
-    s->chroma_vshift = s->source.chroma_format > 1;
-    s->source.chroma_width  = s->source.luma_width  >> s->chroma_hshift;
-    s->source.chroma_height = s->source.luma_height >> s->chroma_vshift;
-
-    if (get_bits1(gb))
-        /* Interlace.  */
-        s->source.interlaced = svq3_get_ue_golomb(gb);
-    if (s->source.interlaced > 1)
-        return -1;
-
-    /* Framerate.  */
-    if (get_bits1(gb)) {
-        s->source.frame_rate_index = svq3_get_ue_golomb(gb);
-
-        if (s->source.frame_rate_index > 10)
-            return -1;
-
-        if (! s->source.frame_rate_index) {
-            s->source.frame_rate.num = svq3_get_ue_golomb(gb);
-            s->source.frame_rate.den = svq3_get_ue_golomb(gb);
-        }
-    }
-    if (s->source.frame_rate_index > 0 && s->source.frame_rate_index <= 10) {
-        if (s->source.frame_rate_index <= 8)
-            s->source.frame_rate = ff_frame_rate_tab[s->source.frame_rate_index];
-        else
-            s->source.frame_rate = ff_dirac_frame_rate[s->source.frame_rate_index-9];
-    }
-
-    /* Override aspect ratio.  */
-    if (get_bits1(gb)) {
-        s->source.aspect_ratio_index = svq3_get_ue_golomb(gb);
-
-        if (s->source.aspect_ratio_index > 6)
-            return -1;
-
-        if (! s->source.aspect_ratio_index) {
-            s->source.aspect_ratio.num = svq3_get_ue_golomb(gb);
-            s->source.aspect_ratio.den = svq3_get_ue_golomb(gb);
-        }
-    }
-    if (s->source.aspect_ratio_index > 0 && s->source.aspect_ratio_index <= 6)
-        s->source.aspect_ratio =
-                ff_dirac_preset_aspect_ratios[s->source.aspect_ratio_index-1];
-
-    /* Override clean area.  */
-    if (get_bits1(gb)) {
-        s->source.clean_width        = svq3_get_ue_golomb(gb);
-        s->source.clean_height       = svq3_get_ue_golomb(gb);
-        s->source.clean_left_offset  = svq3_get_ue_golomb(gb);
-        s->source.clean_right_offset = svq3_get_ue_golomb(gb);
-    }
-
-    /* Override signal range.  */
-    if (get_bits1(gb)) {
-        s->source.signal_range_index = svq3_get_ue_golomb(gb);
-
-        if (s->source.signal_range_index > 4)
-            return -1;
-
-        if (! s->source.signal_range_index) {
-            s->source.luma_offset      = svq3_get_ue_golomb(gb);
-            s->source.luma_excursion   = svq3_get_ue_golomb(gb);
-            s->source.chroma_offset    = svq3_get_ue_golomb(gb);
-            s->source.chroma_excursion = svq3_get_ue_golomb(gb);
-        }
-    }
-    if (s->source.signal_range_index > 0 && s->source.signal_range_index <= 4) {
-        int idx = s->source.signal_range_index - 1;
-        s->source.luma_offset      = ff_dirac_preset_luma_offset     [idx];
-        s->source.luma_excursion   = ff_dirac_preset_luma_excursion  [idx];
-        s->source.chroma_offset    = ff_dirac_preset_chroma_offset   [idx];
-        s->source.chroma_excursion = ff_dirac_preset_chroma_excursion[idx];
-    }
-
-    /* Color spec.  */
-    s->source.color_spec = ff_dirac_color_spec_presets[s->source.color_spec_index];
-    if (get_bits1(gb)) {
-        s->source.color_spec_index = svq3_get_ue_golomb(gb);
-
-        if (s->source.color_spec_index > 4)
-            return -1;
-
-        s->source.color_spec = ff_dirac_color_spec_presets[s->source.color_spec_index];
-
-        if (! s->source.color_spec_index) {
-            /* Color primaries.  */
-            if (get_bits1(gb)) {
-                unsigned int primaries_idx = svq3_get_ue_golomb(gb);
-
-                if (primaries_idx > 3)
-                    return -1;
-
-                s->source.color_spec.primaries = primaries_idx;
-            }
-
-            /* Override matrix.  */
-            if (get_bits1(gb)) {
-                unsigned int matrix_idx = svq3_get_ue_golomb(gb);
-
-                if (matrix_idx > 2)
-                    return -1;
-
-                s->source.color_spec.matrix = matrix_idx;
-            }
-
-            /* Transfer function.  */
-            if (get_bits1(gb)) {
-                unsigned int tf_idx = svq3_get_ue_golomb(gb);
-
-                if (tf_idx > 3)
-                    return -1;
-
-                s->source.color_spec.transfer_function = tf_idx;
-            }
-        }
-    }
-    s->source.k_r = ff_dirac_preset_kr[s->source.color_spec_index];
-    s->source.k_b = ff_dirac_preset_kb[s->source.color_spec_index];
-
-    s->source.luma_depth   = av_log2(s->source.luma_excursion   + 1);
-    s->source.chroma_depth = av_log2(s->source.chroma_excursion + 1);
-
-    return 0;
-}
-
-/**
- * Parse the sequence header
- */
-static int parse_sequence_header(DiracContext *s)
-{
-    GetBitContext *gb = &s->gb;
-    unsigned int version_major;
-    unsigned int version_minor;
-    unsigned int video_format;
-    unsigned int picture_coding_mode;
-
-    /* Parse parameters.  */
-    version_major = svq3_get_ue_golomb(gb);
-    version_minor = svq3_get_ue_golomb(gb);
-    /* XXX: Don't check the version yet, existing encoders do not yet
-       set this to a sane value (0.6 at the moment).  */
-
-    /* XXX: Not yet documented in the spec.  This is actually the main
-       thing that is missing.  */
-    s->profile = svq3_get_ue_golomb(gb);
-    s->level = svq3_get_ue_golomb(gb);
-    dprintf(s->avctx, "Access unit header: Version %d.%d\n",
-            version_major, version_minor);
-    dprintf(s->avctx, "Profile: %d, Level: %d\n", s->profile, s->level);
-
-    video_format = svq3_get_ue_golomb(gb);
-    dprintf(s->avctx, "Video format: %d\n", video_format);
-
-    if (video_format > 20)
-        return -1;
-
-    /* Fill in defaults for the source parameters.  */
-    s->source = ff_dirac_source_parameters_defaults[video_format];
-
-    /* Override the defaults.  */
-    if (parse_source_parameters(s))
-        return -1;
-
-    picture_coding_mode = svq3_get_ue_golomb(gb);
-
-    return 0;
-}
-
-/**
  * Dequantize a coefficient
  *
  * @param coeff coefficient to dequantize
@@ -1044,7 +856,7 @@ int dirac_decode_frame(AVCodecContext *a
     s->avctx = avctx;
 
     if (parse_code ==  pc_seq_header) {
-        if (parse_sequence_header(s))
+        if (ff_dirac_parse_sequence_header(s))
             return -1;
 
         /* Dump the header.  */



More information about the FFmpeg-soc mailing list