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

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


Author: conrad
Date: Wed Dec  3 22:28:38 2008
New Revision: 3846

Log:
Set pix_fmt taking into account pixel range (for full scale YUV)


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:38 2008
@@ -98,10 +98,10 @@ static const color_specification dirac_c
 static const float dirac_preset_kr[] = { 0.2126, 0.299, 0 /* XXX */ };
 static const float dirac_preset_kb[] = { 0.0722, 0.114, 0 /* XXX */ };
 
-static const enum PixelFormat dirac_pix_fmt[] = {
-    PIX_FMT_YUV444P,
-    PIX_FMT_YUV422P,
-    PIX_FMT_YUV420P,
+static const enum PixelFormat dirac_pix_fmt[][2] = {
+    { PIX_FMT_YUV444P, PIX_FMT_YUVJ444P },
+    { PIX_FMT_YUV422P, PIX_FMT_YUVJ422P },
+    { PIX_FMT_YUV420P, PIX_FMT_YUVJ420P },
 };
 
 /* Quarter pixel interpolation. */
@@ -199,7 +199,6 @@ static int parse_source_parameters(GetBi
                source->chroma_format);
         return -1;
     }
-    avctx->pix_fmt = dirac_pix_fmt[source->chroma_format];
 
     if (get_bits1(gb))
         source->interlaced = svq3_get_ue_golomb(gb);
@@ -269,6 +268,13 @@ static int parse_source_parameters(GetBi
         source->pixel_range =
                 dirac_pixel_range_presets[source->pixel_range_index-1];
 
+    if (PIXEL_RANGE_EQUAL(source->pixel_range, dirac_pixel_range_presets[0]))
+        // full range (JPEG YUV colorspace)
+        avctx->pix_fmt = dirac_pix_fmt[source->chroma_format][1];
+    else
+        // normal YUV colorspace as the default
+        avctx->pix_fmt = dirac_pix_fmt[source->chroma_format][0];
+
     /* color spec */
     source->color_spec = dirac_color_spec_presets[source->color_spec_index];
     if (get_bits1(gb)) {

Modified: dirac/libavcodec/dirac.h
==============================================================================
--- dirac/libavcodec/dirac.h	(original)
+++ dirac/libavcodec/dirac.h	Wed Dec  3 22:28:38 2008
@@ -67,6 +67,12 @@ typedef struct {
     uint16_t chroma_excursion;
 } dirac_pixel_range;
 
+#define PIXEL_RANGE_EQUAL(a,b) \
+    (a.luma_offset == b.luma_offset && \
+     a.luma_excursion == b.luma_excursion && \
+     a.chroma_offset == b.chroma_offset && \
+     a.chroma_excursion == b.chroma_excursion)
+
 #define DIRAC_SIGN(x) ((x) > 0 ? 2 : ((x) < 0 ? 1 : 0))
 #define DIRAC_PARSE_INFO_PREFIX 0x42424344
 #define CALC_PADDING(size, depth) \
@@ -93,7 +99,7 @@ typedef struct {
     uint16_t clean_left_offset;
     uint16_t clean_right_offset;
 
-    uint8_t pixel_range_index;        ///< index into dirac_pixel_range_presets[]
+    uint8_t pixel_range_index;         ///< index into dirac_pixel_range_presets[]
     uint8_t color_spec_index;          ///< index into dirac_color_spec_presets[]
 
     dirac_pixel_range pixel_range;



More information about the FFmpeg-soc mailing list