]> git.sesse.net Git - vlc/commitdiff
video_decoder : ajout de la crop table dans AddBlock ;
authorChristophe Massiot <massiot@videolan.org>
Thu, 6 Jan 2000 00:13:19 +0000 (00:13 +0000)
committerChristophe Massiot <massiot@videolan.org>
Thu, 6 Jan 2000 00:13:19 +0000 (00:13 +0000)
video_parser : correction d'une erreur dans le commit pr�c�dent (on ne
fera pas la saturation dans le cas d'une DFT, de toute fa�on)

include/config.h
include/video_decoder.h.new
src/video_decoder/video_decoder.c
src/video_parser/video_parser.c
src/video_parser/vpar_blocks.c

index 29206fc20ab7bfa31bf5462b7786efce54d180d6..1dd01b8712b9ca9d4e20231e202063f19a49c0cd 100644 (file)
  * picture. */
 #define NB_VDEC                         1
 
+/* Maximum range of values out of the IDCT + motion compensation. Only
+ * used if you define MPEG2_COMPLIANT above. */
+#define VDEC_CROPRANGE                  2048
+
 /*******************************************************************************
  * Generic decoder configuration
  *******************************************************************************/
index 849c7f1326454ba6af5d015b4af78ef0fcb8e7e6..ecad1f0f5e9c45f1dba08254fd4400b55cc3a005 100644 (file)
@@ -33,10 +33,15 @@ typedef struct vdec_thread_s
  /*??*/
 //    int *pi_status;
     
-
     /* Input properties */
     struct vpar_thread_s *    p_vpar;                 /* video_parser thread */
         
+    /* Lookup tables */
+#ifdef MPEG2_COMPLIANT
+    u8              pi_crop_buf[VDEC_CROPRANGE];
+    u8 *            pi_crop,
+#endif
+
 #ifdef STATS
     /* Statistics */
     count_t         c_loops;                              /* number of loops */
@@ -54,7 +59,7 @@ typedef struct vdec_thread_s
 /*****************************************************************************
  * Function pointers
  *****************************************************************************/
-typedef void (*f_addb_t)( elem_t*, data_t*, int );
+typedef void (*f_addb_t)( vdec_thread_t*, elem_t*, data_t*, int );
 
 /*****************************************************************************
  * Prototypes
@@ -64,6 +69,6 @@ struct vpar_thread_s;
 /* Thread management functions */
 vdec_thread_t * vdec_CreateThread       ( struct vpar_thread_s *p_vpar /*, int *pi_status */ );
 void            vdec_DestroyThread      ( vdec_thread_t *p_vdec /*, int *pi_status */ );
-void vdec_AddBlock( elem_t*, data_t*, int );
-void vdec_CopyBlock( elem_t*, data_t*, int );
-void vdec_DummyBlock( elem_t*, data_t*, int );
+void vdec_AddBlock( vdec_thread_t*, elem_t*, data_t*, int );
+void vdec_CopyBlock( vdec_thread_t*, elem_t*, data_t*, int );
+void vdec_DummyBlock( vdec_thread_t*, elem_t*, data_t*, int );
index 8651a8e6b724bca6cc6f0a7c8364346032dd0549..1ce936632d4254abb71fcd07034ef85f57dcfd6f 100644 (file)
@@ -126,6 +126,10 @@ void vdec_DestroyThread( vdec_thread_t *p_vdec /*, int *pi_status */ )
  *******************************************************************************/
 static int InitThread( vdec_thread_t *p_vdec )
 {
+#ifdef MPEG2_COMPLIANT
+    int i_dummy;
+#endif
+
     intf_DbgMsg("vdec debug: initializing video decoder thread %p\n", p_vdec);
 
     /* Initialize other properties */
@@ -138,6 +142,23 @@ static int InitThread( vdec_thread_t *p_vdec )
     p_vdec->c_decoded_b_pictures = 0;
 #endif
 
+#ifdef MPEG2_COMPLIANT
+    /* Init crop table */
+    p_vdec->pi_crop = p_vdec->pi_crop_buf + (VDEC_CROPRANGE >> 1);
+    for( i_dummy = -VDEC_CROPRANGE; i_dummy < -256; i_dummy ++ )
+    {
+        p_vdec->pi_crop[i_dummy] = -256;
+    }
+    for( ; i_dummy < 255; i_dummy ++ )
+    {
+        p_vdec->pi_crop[i_dummy] = i_dummy;
+    }
+    for( ; i_dummy < (VDEC_CROPRANGE >> 1) -1; i_dummy++ )
+    {
+        p_vdec->pi_crop[i_dummy] = 255;
+    }
+#endif
+
     /* Mark thread as running and return */
     intf_DbgMsg("vdec debug: InitThread(%p) succeeded\n", p_vdec);    
     return( 0 );    
@@ -278,7 +299,8 @@ static void DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb )
 /*******************************************************************************
  * vdec_AddBlock : add a block
  *******************************************************************************/
-void vdec_AddBlock( elem_t * p_block, data_t * p_data, int i_incr )
+void vdec_AddBlock( vdec_thread_t * p_vdec, elem_t * p_block, data_t * p_data,
+                    int i_incr )
 {
     int i_x, i_y;
     
@@ -286,8 +308,12 @@ void vdec_AddBlock( elem_t * p_block, data_t * p_data, int i_incr )
     {
         for( i_x = 0; i_x < 8; i_x++ )
         {
-            /* ??? Need clip to be MPEG-2 compliant */
+#ifdef MPEG2_COMPLIANT
+            *p_data = p_vdec->pi_clip[*p_data + *p_block++];
+            p_data++;
+#else
             *p_data++ += *p_block++;
+#endif
         }
         p_data += i_incr;
     }
@@ -296,7 +322,8 @@ void vdec_AddBlock( elem_t * p_block, data_t * p_data, int i_incr )
 /*******************************************************************************
  * vdec_CopyBlock : copy a block
  *******************************************************************************/
-void vdec_CopyBlock( elem_t * p_block, data_t * p_data, int i_incr )
+void vdec_CopyBlock( vdec_thread_t * p_vdec, elem_t * p_block, data_t * p_data,
+                     int i_incr )
 {
     int i_x, i_y;
     
@@ -322,6 +349,7 @@ void vdec_CopyBlock( elem_t * p_block, data_t * p_data, int i_incr )
 /*******************************************************************************
  * vdec_DummyBlock : dummy function that does nothing
  *******************************************************************************/
-void vdec_DummyBlock( elem_t * p_block, data_t * p_data, int i_incr )
+void vdec_DummyBlock( vdec_thread_t * p_vdec, elem_t * p_block, data_t * p_data,
+                      int i_incr )
 {
 }
index b23ffd70c7dd92ee17522bfa104568c8ae49a622..90ecbfe626e9e8ef604d36a24e047cedbdca2ead 100644 (file)
@@ -81,7 +81,8 @@ vpar_thread_t * vpar_CreateThread( /* video_cfg_t *p_cfg, */ input_thread_t *p_i
     /*
      * Initialize the input properties
      */
-    /* Initialize the parser fifo's data lock and conditional variable and set     * its buffer as empty */
+    /* Initialize the decoder fifo's data lock and conditional variable and set
+     * its buffer as empty */
     vlc_mutex_init( &p_vpar->fifo.data_lock );
     vlc_cond_init( &p_vpar->fifo.data_wait );
     p_vpar->fifo.i_start = 0;
@@ -221,7 +222,7 @@ static int InitThread( vpar_thread_t *p_vpar )
     }
 
     /* Initialize lookup tables */
-#ifdef MPEG2_COMPLIANT
+#if defined(MPEG2_COMPLIANT) && !defined(VDEC_DFT)
     vpar_InitCrop( p_vpar );
 #endif
     InitMbAddrInc( p_vpar );
index 61e3b25fe45877c587f0f48aed0b8106df0c9963..76f1529e3bf719f7fa1f360141f2adc64b94bd60 100644 (file)
@@ -142,7 +142,7 @@ extern int pi_scan[2][64] =
  * vpar_InitCrop : Initialize the crop table for saturation
  *                 (ISO/IEC 13818-2 section 7.4.3)
  *****************************************************************************/
-#ifdef MPEG2_COMPLIANT
+#if defined(MPEG2_COMPLIANT) && !defined(VDEC_DFT)
 void vpar_InitCrop( vpar_thread_t * p_vpar )
 {
     int i_dummy;