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

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


Author: conrad
Date: Mon Nov 10 04:11:05 2008
New Revision: 3770

Log:
Update parsing source paramaters to the latest specification
The distinction between source and sequence no longer exists


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:05 2008
@@ -37,43 +37,31 @@
 #include "dirac_wavelet.h"
 #include "mpeg12data.h"
 
-/* Defaults for sequence parameters.  */
-const struct sequence_parameters dirac_sequence_parameters_defaults[13] =
-{
-    /* Width   Height   Chroma format   Depth  */
-    {  640,    480,     2,              8  },
-    {  176,    120,     2,              8  },
-    {  176,    144,     2,              8  },
-    {  352,    240,     2,              8  },
-    {  352,    288,     2,              8  },
-    {  704,    480,     2,              8  },
-    {  704,    576,     2,              8  },
-
-    {  720,    480,     2,              8  },
-    {  720,    576,     2,              8  },
-    {  1280,   720,     2,              8  },
-    {  1920,   1080,    2,              8  },
-    {  2048,   1556,    0,              16 },
-    {  4096,   3112,    0,              16 },
-};
-
 /* Defaults for source parameters.  */
-const struct source_parameters dirac_source_parameters_defaults[13] =
+const struct source_parameters dirac_source_parameters_defaults[] =
 {
-    { 0, 1, 0, {30, 1},        {1, 1},   640,  480,  0, 0, 0,  255,   128,   254,   0, 0, 0.2126, 0.0722, TRANSFER_FUNC_TV },
-    { 0, 1, 0, {15000, 1001},  {10, 11}, 176,  120,  0, 0, 0,  255,   128,   254,   1, 0, 0.299,  0.144,  TRANSFER_FUNC_TV },
-    { 0, 1, 0, {25, 2},        {12, 11}, 176,  144,  0, 0, 0,  255,   128,   254,   2, 0, 0.299,  0.144,  TRANSFER_FUNC_TV },
-    { 0, 1, 0, {15000, 1001},  {10, 11}, 352,  240,  0, 0, 0,  255,   128,   254,   1, 0, 0.299,  0.144,  TRANSFER_FUNC_TV },
-    { 0, 1, 0, {25, 2},        {12, 11}, 352,  288,  0, 0, 0,  255,   128,   254,   2, 0, 0.299,  0.144,  TRANSFER_FUNC_TV },
-    { 0, 1, 0, {15000, 1001},  {10, 11}, 704,  480,  0, 0, 0,  255,   128,   254,   1, 0, 0.299,  0.144,  TRANSFER_FUNC_TV },
-    { 0, 1, 0, {25, 2},        {12, 11}, 704,  576,  0, 0, 0,  255,   128,   254,   2, 0, 0.299,  0.144,  TRANSFER_FUNC_TV },
+    { 640,  480,  2, 0, 0, 1,  1, 640,  480,  0, 0, 1, 0 },
+    { 176,  120,  2, 0, 0, 9,  2, 176,  120,  0, 0, 1, 1 },
+    { 176,  144,  2, 0, 1, 10, 3, 176,  144,  0, 0, 1, 2 },
+    { 352,  240,  2, 0, 0, 9,  2, 352,  240,  0, 0, 1, 1 },
+    { 352,  288,  2, 0, 1, 10, 3, 352,  288,  0, 0, 1, 2 },
+    { 704,  480,  2, 0, 0, 9,  2, 704,  480,  0, 0, 1, 1 },
+    { 704,  576,  2, 0, 1, 10, 3, 704,  576,  0, 0, 1, 2 },
+    { 720,  480,  1, 1, 0, 4,  2, 704,  480,  8, 0, 3, 1 },
+    { 720,  576,  1, 1, 1, 3,  3, 704,  576,  8, 0, 3, 2 },
 
-    { 0, 1, 0, {24000, 1001},  {10, 11}, 720,  480,  0, 0, 16, 235,   128,   224,   1, 0, 0.299,  0.144,  TRANSFER_FUNC_TV },
-    { 0, 1, 0, {35, 1},        {12, 11}, 720,  576,  0, 0, 16, 235,   128,   224,   2, 0, 0.299,  0.144,  TRANSFER_FUNC_TV },
-    { 0, 1, 0, {24, 1},        {1, 1},   1280, 720,  0, 0, 16, 235,   128,   224,   0, 0, 0.2126, 0.0722, TRANSFER_FUNC_TV },
-    { 0, 1, 0, {24, 1},        {1, 1},   1920, 1080, 0, 0, 16, 235,   128,   224,   0, 0, 0.2126, 0.0722, TRANSFER_FUNC_TV },
-    { 0, 1, 0, {24, 1},        {1, 1},   2048, 1536, 0, 0, 0,  65535, 32768, 65534, 3, 0, 0.25,   0.25,   TRANSFER_FUNC_LINEAR },
-    { 0, 1, 0, {24, 1},        {1, 1},   4096, 3072, 0, 0, 0,  65535, 32768, 65534, 3, 0, 0.25,   0.25,   TRANSFER_FUNC_LINEAR },
+    { 1280, 720,  1, 0, 1, 7,  1, 1280, 720,  0, 0, 3, 3 },
+    { 1280, 720,  1, 0, 1, 6,  1, 1280, 720,  0, 0, 3, 3 },
+    { 1920, 1080, 1, 1, 1, 4,  1, 1920, 1080, 0, 0, 3, 3 },
+    { 1920, 1080, 1, 1, 1, 3,  1, 1920, 1080, 0, 0, 3, 3 },
+    { 1920, 1080, 1, 0, 1, 7,  1, 1920, 1080, 0, 0, 3, 3 },
+    { 2048, 1080, 0, 0, 1, 2,  1, 2048, 1080, 0, 0, 4, 4 },
+    { 4096, 2160, 0, 0, 1, 2,  1, 4096, 2160, 0, 0, 4, 4 },
+
+    { 3840, 2160, 1, 0, 1, 7,  1, 3840, 2160, 0, 0, 3, 3 },
+    { 3840, 2160, 1, 0, 1, 6,  1, 3840, 2160, 0, 0, 3, 3 },
+    { 7680, 4320, 1, 0, 1, 7,  1, 3840, 2160, 0, 0, 3, 3 },
+    { 7680, 4320, 1, 0, 1, 6,  1, 3840, 2160, 0, 0, 3, 3 },
 };
 
 /* Defaults for decoding parameters.  */
@@ -95,22 +83,31 @@ const struct decoding_parameters dirac_d
     { 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[3] =
+const AVRational dirac_preset_aspect_ratios[] =
 {
-    {1, 1}, {10, 11}, {12, 11}
+    {1, 1}, {10, 11}, {12, 11},
+    {40, 33},
+    {16, 11},
+    {4, 3},
 };
 
-const uint8_t dirac_preset_luma_offset[3] = { 0, 16, 64 };
-const uint16_t dirac_preset_luma_excursion[3] = { 255, 235, 876 };
-const uint16_t dirac_preset_chroma_offset[3] = { 128, 128, 512 };
-const uint16_t dirac_preset_chroma_excursion[3] = { 255, 224, 896 };
-
-const uint8_t dirac_preset_primaries[4] = { 0, 1, 2, 3 };
-const uint8_t dirac_preset_matrix[4] = {0, 1, 1, 2 };
-const transfer_func_t dirac_preset_transfer_func[4] =
+const AVRational ff_dirac_frame_rate[] =
 {
-    TRANSFER_FUNC_TV, TRANSFER_FUNC_TV,
-    TRANSFER_FUNC_TV, TRANSFER_FUNC_DCI_GAMMA
+    {15000, 1001},
+    {25, 2},
+};
+
+const uint16_t dirac_preset_luma_offset[] = { 0, 16, 64, 256 };
+const uint16_t dirac_preset_luma_excursion[] = { 255, 219, 876, 3504 };
+const uint16_t dirac_preset_chroma_offset[] = { 128, 128, 512, 2048 };
+const uint16_t dirac_preset_chroma_excursion[] = { 255, 224, 896, 3584 };
+
+const color_specification ff_dirac_color_spec_presets[] = {
+    { COLOR_PRIMARY_HDTV,     COLOR_MATRIX_HDTV, TRANSFER_FUNC_TV },
+    { COLOR_PRIMARY_SDTV_525, COLOR_MATRIX_SDTV, TRANSFER_FUNC_TV },
+    { COLOR_PRIMARY_SDTV_625, COLOR_MATRIX_SDTV, TRANSFER_FUNC_TV },
+    { COLOR_PRIMARY_HDTV,     COLOR_MATRIX_HDTV, TRANSFER_FUNC_TV },
+    { COLOR_PRIMARY_HDTV,     COLOR_MATRIX_HDTV, TRANSFER_FUNC_DCI_GAMMA },
 };
 const float dirac_preset_kr[3] = { 0.2126, 0.299, 0 /* XXX */ };
 const float dirac_preset_kb[3] = {0.0722, 0.114, 0 /* XXX */ };
@@ -146,45 +143,28 @@ const weights_t eighthpel_weights[16] = 
 };
 
 /**
- * Dump the sequence parameters.  DEBUG needs to be defined.
- */
-void dirac_dump_sequence_parameters(AVCodecContext *avctx) {
-    DiracContext *s = avctx->priv_data;
-    struct sequence_parameters *seq = &s->sequence;
-    const char *chroma_format_str[] = { "4:4:4", "4:2:2", "4:2:0" };
-
-    dprintf(avctx, "-----------------------------------------------------\n");
-    dprintf(avctx, "        Dumping the sequence parameters:\n");
-    dprintf(avctx, "-----------------------------------------------------\n");
-
-
-    dprintf(avctx, "Luma size=%dx%d\n",
-            seq->luma_width, seq->luma_height);
-    dprintf(avctx, "Chroma size=%dx%d, format: %s\n",
-            seq->chroma_width, seq->chroma_height,
-            chroma_format_str[seq->chroma_format]);
-    dprintf(avctx, "Video depth: %d bpp\n", seq->video_depth);
-
-    dprintf(avctx, "-----------------------------------------------------\n");
-
-}
-
-/**
  * Dump the source parameters.  DEBUG needs to be defined.
  */
 void dirac_dump_source_parameters(AVCodecContext *avctx) {
     DiracContext *s = avctx->priv_data;
     struct source_parameters *source = &s->source;
+    const char *chroma_format_str[] = { "4:4:4", "4:2:2", "4:2:0" };
 
     dprintf(avctx, "-----------------------------------------------------\n");
     dprintf(avctx, "        Dumping source parameters:\n");
     dprintf(avctx, "-----------------------------------------------------\n");
 
+    dprintf(avctx, "Luma size=%dx%d\n",
+            source->luma_width, source->luma_height);
+    dprintf(avctx, "Chroma size=%dx%d, format: %s\n",
+            source->chroma_width, source->chroma_height,
+            chroma_format_str[source->chroma_format]);
+
     if (! source->interlaced)
         dprintf(avctx, "No interlacing\n");
     else
-        dprintf(avctx, "Interlacing: top fields first=%d\n, seq. fields=%d\n",
-                source->top_field_first, source->sequential_fields);
+        dprintf(avctx, "Interlacing: top fields first=%d\n",
+                source->top_field_first);
 
     dprintf(avctx, "Frame rate: %d/%d = %f\n",
             source->frame_rate.num, source->frame_rate.den,
@@ -942,15 +922,15 @@ int dirac_motion_compensation(DiracConte
     int hbits, vbits;
 
     if (comp == 0) {
-        s->width  = s->sequence.luma_width;
-        s->height = s->sequence.luma_height;
+        s->width  = s->source.luma_width;
+        s->height = s->source.luma_height;
         s->xblen  = s->frame_decoding.luma_xblen;
         s->yblen  = s->frame_decoding.luma_yblen;
         s->xbsep  = s->frame_decoding.luma_xbsep;
         s->ybsep  = s->frame_decoding.luma_ybsep;
     } else {
-        s->width  = s->sequence.chroma_width;
-        s->height = s->sequence.chroma_height;
+        s->width  = s->source.chroma_width;
+        s->height = s->source.chroma_height;
         s->xblen  = s->frame_decoding.chroma_xblen;
         s->yblen  = s->frame_decoding.chroma_yblen;
         s->xbsep  = s->frame_decoding.chroma_xbsep;

Modified: dirac/libavcodec/dirac.h
==============================================================================
--- dirac/libavcodec/dirac.h	(original)
+++ dirac/libavcodec/dirac.h	Mon Nov 10 04:11:05 2008
@@ -35,12 +35,31 @@
 #include "dirac_arith.h"
 
 typedef enum {
+    COLOR_PRIMARY_HDTV,         ///< ITU-R BT. 709, also computer/web/sRGB
+    COLOR_PRIMARY_SDTV_525,     ///< SMPTE 170M, 525 primaries
+    COLOR_PRIMARY_SDTV_625,     ///< EBU Tech 3213-E, 625 primaries
+    COLOR_PRIMARY_DCINEMA,      ///< SMPTE 428.1, CIE XYZ
+} color_primary_t;
+
+typedef enum {
+    COLOR_MATRIX_HDTV,          ///< ITU-R BT.709, also computer/web
+    COLOR_MATRIX_SDTV,          ///< ITU-R BT.601
+    COLOR_MATRIX_REVERSIBLE,    ///< ITU-T H.264
+} color_matrix_t;
+
+typedef enum {
     TRANSFER_FUNC_TV,
     TRANSFER_FUNC_EXTENDED_GAMUT,
     TRANSFER_FUNC_LINEAR,
     TRANSFER_FUNC_DCI_GAMMA
 } transfer_func_t;
 
+typedef struct {
+    color_primary_t primaries;
+    color_matrix_t  matrix;
+    transfer_func_t transfer_function;
+} color_specification;
+
 #define DIRAC_SIGN(x) ((x) > 0 ? 2 : ((x) < 0 ? 1 : 0))
 #define DIRAC_PARSE_INFO_PREFIX 0x42424344
 #define CALC_PADDING(size, depth) \
@@ -49,14 +68,18 @@ typedef enum {
 
 struct source_parameters
 {
+    /* Information about the frames.  */
+    unsigned int luma_width;                ///< the luma component width
+    unsigned int luma_height;               ///< the luma component height
+    /** Choma format: 0: 4:4:4, 1: 4:2:2, 2: 4:2:0 */
+    unsigned int chroma_format;
+
     /* Interlacing.  */
     char interlaced;                   ///< flag for interlacing
     char top_field_first;
-    char sequential_fields;
-
-    AVRational frame_rate;             ///< frame rate
 
-    AVRational aspect_ratio;           ///< aspect ratio
+    unsigned int frame_rate_index;     ///< index into dirac_frame_rate[]
+    unsigned int aspect_ratio_index;   ///< index into dirac_aspect_ratio[]
 
     /* Clean area.  */
     uint16_t clean_width;
@@ -64,33 +87,25 @@ struct source_parameters
     uint16_t clean_left_offset;
     uint16_t clean_right_offset;
 
+    unsigned int signal_range_index;   ///< index into dirac_signal_range[]
+    unsigned int color_spec_index;     ///< index into ff_dirac_color_spec_presets[]
+
+    /* Calculated:  */
+    unsigned int chroma_width;              ///< the chroma component width
+    unsigned int chroma_height;             ///< the chroma component height
+
+    AVRational frame_rate;
+    AVRational aspect_ratio;
+
     /* Luma and chroma offsets.  */
     uint16_t luma_offset;
     uint16_t luma_excursion;
     uint16_t chroma_offset;
     uint16_t chroma_excursion;
 
-    uint16_t color_spec;
-    uint16_t color_primaries; /* XXX: ??? */
-
+    color_specification color_spec;
     float k_r;
     float k_b; /* XXX: ??? */
-
-    transfer_func_t transfer_function;
-};
-
-struct sequence_parameters
-{
-    /* Information about the frames.  */
-    unsigned int luma_width;                ///< the luma component width
-    unsigned int luma_height;               ///< the luma component height
-    /** Choma format: 0: 4:4:4, 1: 4:2:2, 2: 4:2:0 */
-    unsigned int chroma_format;
-    unsigned char video_depth;              ///< depth in bits
-
-    /* Calculated:  */
-    unsigned int chroma_width;              ///< the chroma component width
-    unsigned int chroma_height;             ///< the chroma component height
 };
 
 struct decoding_parameters
@@ -137,16 +152,16 @@ struct globalmc_parameters {
 };
 
 /* Defaults for sequence parameters.  */
-extern const struct sequence_parameters dirac_sequence_parameters_defaults[13];
-extern const struct source_parameters dirac_source_parameters_defaults[13];
+extern const struct source_parameters dirac_source_parameters_defaults[];
 extern const struct decoding_parameters dirac_decoding_parameters_defaults[13];
-extern const AVRational dirac_preset_aspect_ratios[3];
-extern const uint8_t dirac_preset_luma_offset[3];
-extern const uint16_t dirac_preset_luma_excursion[3];
-extern const uint16_t dirac_preset_chroma_offset[3];
-extern const uint16_t dirac_preset_chroma_excursion[3];
+extern const AVRational ff_dirac_frame_rate[];
+extern const AVRational dirac_preset_aspect_ratios[];
+extern const uint16_t dirac_preset_luma_offset[];
+extern const uint16_t dirac_preset_luma_excursion[];
+extern const uint16_t dirac_preset_chroma_offset[];
+extern const uint16_t dirac_preset_chroma_excursion[];
+extern const color_specification ff_dirac_color_spec_presets[];
 extern const uint8_t dirac_preset_primaries[4];
-extern const uint8_t dirac_preset_matrix[4];
 extern const transfer_func_t dirac_preset_transfer_func[4];
 extern const float dirac_preset_kr[3];
 extern const float dirac_preset_kb[3];
@@ -199,7 +214,6 @@ typedef struct DiracContext {
     int16_t *mcpic;
 
     struct source_parameters source;
-    struct sequence_parameters sequence;
     struct decoding_parameters decoding;
 
     struct decoding_parameters frame_decoding;
@@ -586,8 +600,6 @@ int dirac_motion_compensation(DiracConte
 int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
                        uint8_t *buf, int buf_size);
 
-void dirac_dump_sequence_parameters(AVCodecContext *avctx);
-
 void dirac_dump_source_parameters(AVCodecContext *avctx);
 
 #endif /* AVCODEC_DIRAC_H */

Modified: dirac/libavcodec/diracdec.c
==============================================================================
--- dirac/libavcodec/diracdec.c	(original)
+++ dirac/libavcodec/diracdec.c	Mon Nov 10 04:11:05 2008
@@ -50,79 +50,66 @@ static int decode_end(AVCodecContext *av
 }
 
 /**
- * Parse the sequence parameters in the access unit header
+ * Parse the source parameters in the access unit header
  */
-static void parse_sequence_parameters(DiracContext *s) {
+static int parse_source_parameters(DiracContext *s) {
     GetBitContext *gb = &s->gb;
 
     /* Override the luma dimensions.  */
     if (get_bits1(gb)) {
-        s->sequence.luma_width  = svq3_get_ue_golomb(gb);
-        s->sequence.luma_height = svq3_get_ue_golomb(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->sequence.chroma_format = svq3_get_ue_golomb(gb);
+        s->source.chroma_format = svq3_get_ue_golomb(gb);
 
     /* Calculate the chroma dimensions.  */
-    s->chroma_hshift = s->sequence.chroma_format > 0;
-    s->chroma_vshift = s->sequence.chroma_format > 1;
-    s->sequence.chroma_width  = s->sequence.luma_width  >> s->chroma_hshift;
-    s->sequence.chroma_height = s->sequence.luma_height >> s->chroma_vshift;
-}
-
-/**
- * Parse the source parameters in the access unit header
- */
-static int parse_source_parameters(DiracContext *s) {
-    GetBitContext *gb = &s->gb;
+    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;
 
-    /* Access Unit Source parameters.  */
     if (get_bits1(gb)) {
         /* Interlace.  */
         s->source.interlaced = get_bits1(gb);
-
-        if (s->source.interlaced) {
-            if (get_bits1(gb))
-                s->source.top_field_first = get_bits1(gb);
-
-            if (get_bits1(gb))
-                s->source.sequential_fields = get_bits1(gb);
-        }
     }
 
     /* Framerate.  */
     if (get_bits1(gb)) {
-        unsigned int idx = svq3_get_ue_golomb(gb);
+        s->source.frame_rate_index = svq3_get_ue_golomb(gb);
 
-        if (idx > 8)
+        if (s->source.frame_rate_index > 10)
             return -1;
 
-        if (! idx) {
+        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);
-        } else {
-            /* Use a pre-set framerate.  */
-            s->source.frame_rate = ff_frame_rate_tab[idx];
         }
     }
+    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)) {
-        unsigned int idx = svq3_get_ue_golomb(gb);
+        s->source.aspect_ratio_index = svq3_get_ue_golomb(gb);
 
-        if (idx > 3)
+        if (s->source.aspect_ratio_index > 6)
             return -1;
 
-        if (! idx) {
+        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);
-        } else {
-            /* Use a pre-set aspect ratio.  */
-            s->source.aspect_ratio = dirac_preset_aspect_ratios[idx - 1];
         }
     }
+    if (s->source.aspect_ratio_index > 0 && s->source.aspect_ratio_index <= 6)
+        s->source.aspect_ratio =
+                   dirac_preset_aspect_ratios[s->source.aspect_ratio_index-1];
 
     /* Override clean area.  */
     if (get_bits1(gb)) {
@@ -134,40 +121,37 @@ static int parse_source_parameters(Dirac
 
     /* Override signal range.  */
     if (get_bits1(gb)) {
-        unsigned int idx = svq3_get_ue_golomb(gb);
+        s->source.signal_range_index = svq3_get_ue_golomb(gb);
 
-        if (idx > 3)
+        if (s->source.signal_range_index > 4)
             return -1;
 
-        if (! idx) {
+        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);
-        } else {
-            /* Use a pre-set signal range.  */
-            s->source.luma_offset = dirac_preset_luma_offset[idx - 1];
-            s->source.luma_excursion = dirac_preset_luma_excursion[idx - 1];
-            s->source.chroma_offset = dirac_preset_chroma_offset[idx - 1];
-            s->source.chroma_excursion = dirac_preset_chroma_excursion[idx - 1];
         }
     }
+    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      = dirac_preset_luma_offset     [idx];
+        s->source.luma_excursion   = dirac_preset_luma_excursion  [idx];
+        s->source.chroma_offset    = dirac_preset_chroma_offset   [idx];
+        s->source.chroma_excursion = 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)) {
-        unsigned int idx = svq3_get_ue_golomb(gb);
+        s->source.color_spec_index = svq3_get_ue_golomb(gb);
 
-        if (idx > 3)
+        if (s->source.color_spec_index > 4)
             return -1;
 
-        s->source.color_primaries = dirac_preset_primaries[idx];
-        s->source.k_r = dirac_preset_kr[dirac_preset_matrix[idx]];
-        s->source.k_b = dirac_preset_kb[dirac_preset_matrix[idx]];
-        s->source.transfer_function = dirac_preset_transfer_func[idx];
-
-        /* XXX: color_spec?  */
+        s->source.color_spec = ff_dirac_color_spec_presets[s->source.color_spec_index];
 
-        if (! idx) {
+        if (! s->source.color_spec_index) {
             /* Color primaries.  */
             if (get_bits1(gb)) {
                 unsigned int primaries_idx = svq3_get_ue_golomb(gb);
@@ -175,18 +159,17 @@ static int parse_source_parameters(Dirac
                 if (primaries_idx > 3)
                     return -1;
 
-                s->source.color_primaries = dirac_preset_primaries[primaries_idx];
+                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 > 3)
+                if (matrix_idx > 2)
                     return -1;
 
-                s->source.k_r = dirac_preset_kr[dirac_preset_matrix[matrix_idx]];
-                s->source.k_b = dirac_preset_kb[dirac_preset_matrix[matrix_idx]];
+                s->source.color_spec.matrix = matrix_idx;
             }
 
             /* Transfer function.  */
@@ -196,12 +179,12 @@ static int parse_source_parameters(Dirac
                 if (tf_idx > 3)
                     return -1;
 
-                s->source.transfer_function = dirac_preset_transfer_func[tf_idx];
+                s->source.color_spec.transfer_function = tf_idx;
             }
-        } else {
-            /* XXX: Use the index.  */
         }
     }
+    s->source.k_r = dirac_preset_kr[s->source.color_spec_index];
+    s->source.k_b = dirac_preset_kb[s->source.color_spec_index];
 
     return 0;
 }
@@ -214,6 +197,7 @@ static int parse_sequence_header(DiracCo
     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);
@@ -232,15 +216,9 @@ static int parse_sequence_header(DiracCo
     video_format = svq3_get_ue_golomb(gb);
     dprintf(s->avctx, "Video format: %d\n", video_format);
 
-    if (video_format > 12)
+    if (video_format > 20)
         return -1;
 
-    /* Fill in defaults for the sequence parameters.  */
-    s->sequence = dirac_sequence_parameters_defaults[video_format];
-
-    /* Override the defaults.  */
-    parse_sequence_parameters(s);
-
     /* Fill in defaults for the source parameters.  */
     s->source = dirac_source_parameters_defaults[video_format];
 
@@ -248,6 +226,8 @@ static int parse_sequence_header(DiracCo
     if (parse_source_parameters(s))
         return -1;
 
+    picture_coding_mode = svq3_get_ue_golomb(gb);
+
     /* Fill in defaults for the decoding parameters.  */
     s->decoding = dirac_decoding_parameters_defaults[video_format];
 
@@ -692,9 +672,9 @@ static int dirac_unpack_prediction_data(
 
 #define DIVRNDUP(a, b) ((a + b - 1) / b)
 
-    s->sbwidth  = DIVRNDUP(s->sequence.luma_width,
+    s->sbwidth  = DIVRNDUP(s->source.luma_width,
                            (s->frame_decoding.luma_xbsep << 2));
-    s->sbheight = DIVRNDUP(s->sequence.luma_height,
+    s->sbheight = DIVRNDUP(s->source.luma_height,
                            (s->frame_decoding.luma_ybsep << 2));
     s->blwidth  = s->sbwidth  << 2;
     s->blheight = s->sbheight << 2;
@@ -890,13 +870,13 @@ START_TIMER
         int width, height;
 
         if (comp == 0) {
-            width            = s->sequence.luma_width;
-            height           = s->sequence.luma_height;
+            width            = s->source.luma_width;
+            height           = s->source.luma_height;
             s->padded_width  = s->padded_luma_width;
             s->padded_height = s->padded_luma_height;
         } else {
-            width            = s->sequence.chroma_width;
-            height           = s->sequence.chroma_height;
+            width            = s->source.chroma_width;
+            height           = s->source.chroma_height;
             s->padded_width  = s->padded_chroma_width;
             s->padded_height = s->padded_chroma_height;
         }
@@ -1037,13 +1017,13 @@ static int parse_frame(DiracContext *s)
          (((size + (1 << depth) - 1) >> depth) << depth)
 
     /* Round up to a multiple of 2^depth.  */
-    s->padded_luma_width    = CALC_PADDING(s->sequence.luma_width,
+    s->padded_luma_width    = CALC_PADDING(s->source.luma_width,
                                            s->frame_decoding.wavelet_depth);
-    s->padded_luma_height   = CALC_PADDING(s->sequence.luma_height,
+    s->padded_luma_height   = CALC_PADDING(s->source.luma_height,
                                            s->frame_decoding.wavelet_depth);
-    s->padded_chroma_width  = CALC_PADDING(s->sequence.chroma_width,
+    s->padded_chroma_width  = CALC_PADDING(s->source.chroma_width,
                                            s->frame_decoding.wavelet_depth);
-    s->padded_chroma_height = CALC_PADDING(s->sequence.chroma_height,
+    s->padded_chroma_height = CALC_PADDING(s->source.chroma_height,
                                            s->frame_decoding.wavelet_depth);
 
     return 0;
@@ -1083,7 +1063,6 @@ int dirac_decode_frame(AVCodecContext *a
 
         /* Dump the header.  */
 #if 0
-        dirac_dump_sequence_parameters(avctx);
         dirac_dump_source_parameters(avctx);
 #endif
 
@@ -1101,15 +1080,15 @@ int dirac_decode_frame(AVCodecContext *a
 
     avctx->pix_fmt = PIX_FMT_YUVJ420P; /* XXX */
 
-    if (avcodec_check_dimensions(avctx, s->sequence.luma_width,
-                                 s->sequence.luma_height)) {
+    if (avcodec_check_dimensions(avctx, s->source.luma_width,
+                                 s->source.luma_height)) {
         av_log(avctx, AV_LOG_ERROR,
                "avcodec_check_dimensions() failed\n");
         return -1;
     }
 
-    avcodec_set_dimensions(avctx, s->sequence.luma_width,
-                           s->sequence.luma_height);
+    avcodec_set_dimensions(avctx, s->source.luma_width,
+                           s->source.luma_height);
 
     if (s->picture.data[0] != NULL)
         avctx->release_buffer(avctx, &s->picture);



More information about the FFmpeg-soc mailing list