]> git.videolan.org Git - x264.git/commitdiff
no more decoder. it never worked anyway, and the presence of defunct code was confusi...
authorLoren Merritt <pengvado@videolan.org>
Tue, 10 Oct 2006 05:05:55 +0000 (05:05 +0000)
committerLoren Merritt <pengvado@videolan.org>
Tue, 10 Oct 2006 05:05:55 +0000 (05:05 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@588 df754926-b1dd-0310-bc7b-ec298dee348c

build/win32/libx264.dsp
common/cabac.h
decoder/decoder.c [deleted file]
decoder/macroblock.c [deleted file]
decoder/macroblock.h [deleted file]
decoder/set.c [deleted file]
decoder/set.h [deleted file]
decoder/vlc.c [deleted file]
decoder/vlc.h [deleted file]
x264.c
x264.h

index d7936c5f9ccd68979062a82d0b66b8966ed6e01a..bfb87153b26724143de3583eb7e887d993b09f54 100644 (file)
@@ -805,127 +805,6 @@ SOURCE=..\..\common\i386\mc-c.c
 \r
 !ENDIF \r
 \r
-# End Source File\r
-# End Group\r
-# Begin Group "Dec"\r
-\r
-# PROP Default_Filter ".c"\r
-# Begin Group "dec_h"\r
-\r
-# PROP Default_Filter ".h"\r
-# Begin Source File\r
-\r
-SOURCE=..\..\decoder\macroblock.h\r
-\r
-!IF  "$(CFG)" == "libx264 - Win32 Release"\r
-\r
-# PROP Intermediate_Dir "obj/dec_release"\r
-\r
-!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"\r
-\r
-# PROP Intermediate_Dir "obj/dec_debug"\r
-\r
-!ENDIF \r
-\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\decoder\set.h\r
-\r
-!IF  "$(CFG)" == "libx264 - Win32 Release"\r
-\r
-# PROP Intermediate_Dir "obj/dec_release"\r
-\r
-!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"\r
-\r
-# PROP Intermediate_Dir "obj/dec_debug"\r
-\r
-!ENDIF \r
-\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\decoder\vlc.h\r
-\r
-!IF  "$(CFG)" == "libx264 - Win32 Release"\r
-\r
-# PROP Intermediate_Dir "obj/dec_release"\r
-\r
-!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"\r
-\r
-# PROP Intermediate_Dir "obj/dec_debug"\r
-\r
-!ENDIF \r
-\r
-# End Source File\r
-# End Group\r
-# Begin Source File\r
-\r
-SOURCE=..\..\decoder\decoder.c\r
-\r
-!IF  "$(CFG)" == "libx264 - Win32 Release"\r
-\r
-# PROP Intermediate_Dir "obj/dec_release"\r
-# PROP Exclude_From_Build 1\r
-\r
-!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"\r
-\r
-# PROP Intermediate_Dir "obj/dec_debug"\r
-# PROP Exclude_From_Build 1\r
-\r
-!ENDIF \r
-\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\decoder\macroblock.c\r
-\r
-!IF  "$(CFG)" == "libx264 - Win32 Release"\r
-\r
-# PROP Intermediate_Dir "obj/dec_release"\r
-# PROP Exclude_From_Build 1\r
-\r
-!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"\r
-\r
-# PROP Intermediate_Dir "obj/dec_debug"\r
-# PROP Exclude_From_Build 1\r
-\r
-!ENDIF \r
-\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\decoder\set.c\r
-\r
-!IF  "$(CFG)" == "libx264 - Win32 Release"\r
-\r
-# PROP Intermediate_Dir "obj/dec_release"\r
-# PROP Exclude_From_Build 1\r
-\r
-!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"\r
-\r
-# PROP Intermediate_Dir "obj/dec_debug"\r
-# PROP Exclude_From_Build 1\r
-\r
-!ENDIF \r
-\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\decoder\vlc.c\r
-\r
-!IF  "$(CFG)" == "libx264 - Win32 Release"\r
-\r
-# PROP Intermediate_Dir "obj/dec_release"\r
-# PROP Exclude_From_Build 1\r
-\r
-!ELSEIF  "$(CFG)" == "libx264 - Win32 Debug"\r
-\r
-# PROP Intermediate_Dir "obj/dec_debug"\r
-# PROP Exclude_From_Build 1\r
-\r
-!ENDIF \r
-\r
 # End Source File\r
 # End Group\r
 # Begin Group "extras"\r
index a8dadf4eae7b6e3e76752fdf5ec776323a372f9b..9009314d5eafa8f3d639c56f014e8aa2859e3e74 100644 (file)
@@ -40,10 +40,10 @@ typedef struct
 
 } x264_cabac_t;
 
-/* encoder/decoder: init the contexts given i_slice_type, the quantif and the model */
+/* init the contexts given i_slice_type, the quantif and the model */
 void x264_cabac_context_init( x264_cabac_t *cb, int i_slice_type, int i_qp, int i_model );
 
-/* decoder only: */
+/* decoder only (unused): */
 void x264_cabac_decode_init    ( x264_cabac_t *cb, bs_t *s );
 int  x264_cabac_decode_decision( x264_cabac_t *cb, int i_ctx_idx );
 int  x264_cabac_decode_bypass  ( x264_cabac_t *cb );
@@ -55,7 +55,8 @@ void x264_cabac_encode_decision( x264_cabac_t *cb, int i_ctx_idx, int b );
 void x264_cabac_encode_bypass( x264_cabac_t *cb, int b );
 void x264_cabac_encode_terminal( x264_cabac_t *cb, int b );
 void x264_cabac_encode_flush( x264_cabac_t *cb );
-/* don't write the bitstream, just calculate cost: */
+
+/* internal only. these don't write the bitstream, just calculate bit cost: */
 void x264_cabac_size_decision( x264_cabac_t *cb, int i_ctx, int b );
 int  x264_cabac_size_decision2( uint8_t *state, int b );
 int  x264_cabac_size_decision_noup( uint8_t *state, int b );
diff --git a/decoder/decoder.c b/decoder/decoder.c
deleted file mode 100644 (file)
index 57bace5..0000000
+++ /dev/null
@@ -1,772 +0,0 @@
-/*****************************************************************************
- * x264: h264 decoder
- *****************************************************************************
- * Copyright (C) 2003 Laurent Aimar
- * $Id: decoder.c,v 1.1 2004/06/03 19:27:07 fenrir Exp $
- *
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-
-#include "common/common.h"
-#include "common/cpu.h"
-#include "common/vlc.h"
-
-#include "macroblock.h"
-#include "set.h"
-#include "vlc.h"
-
-
-static void x264_slice_idr( x264_t *h )
-{
-    int i;
-
-    h->i_poc_msb = 0;
-    h->i_poc_lsb = 0;
-    h->i_frame_offset = 0;
-    h->i_frame_num = 0;
-
-    if( h->sps )
-    {
-        for( i = 0; i < h->sps->i_num_ref_frames + 1; i++ )
-        {
-            h->freference[i]->i_poc = -1;
-        }
-
-        h->fdec = h->freference[0];
-        h->i_ref0 = 0;
-        h->i_ref1 = 0;
-    }
-}
-
-/* The slice reading is split in two part:
- *      - before ref_pic_list_reordering( )
- *      - after  dec_ref_pic_marking( )
- */
-static int x264_slice_header_part1_read( bs_t *s,
-                                         x264_slice_header_t *sh, x264_sps_t sps_array[32], x264_pps_t pps_array[256], int b_idr )
-{
-    sh->i_first_mb = bs_read_ue( s );
-    sh->i_type = bs_read_ue( s );
-    if( sh->i_type >= 5 )
-    {
-        sh->i_type -= 5;
-    }
-    sh->i_pps_id = bs_read_ue( s );
-    if( bs_eof( s ) || sh->i_pps_id >= 256 || pps_array[sh->i_pps_id].i_id == -1 )
-    {
-        fprintf( stderr, "invalid pps_id in slice header\n" );
-        return -1;
-    }
-
-    sh->pps = &pps_array[sh->i_pps_id];
-    sh->sps = &sps_array[sh->pps->i_sps_id];    /* valid if pps valid */
-
-    sh->i_frame_num = bs_read( s, sh->sps->i_log2_max_frame_num );
-    if( !sh->sps->b_frame_mbs_only )
-    {
-        sh->b_field_pic = bs_read1( s );
-        if( sh->b_field_pic )
-        {
-            sh->b_bottom_field = bs_read1( s );
-        }
-    }
-
-    if( b_idr )
-    {
-        sh->i_idr_pic_id = bs_read_ue( s );
-    }
-    else
-    {
-        sh->i_idr_pic_id = 0;
-    }
-
-    if( sh->sps->i_poc_type == 0 )
-    {
-        sh->i_poc_lsb = bs_read( s, sh->sps->i_log2_max_poc_lsb );
-        if( sh->pps->b_pic_order && !sh->b_field_pic )
-        {
-            sh->i_delta_poc_bottom = bs_read_se( s );
-        }
-    }
-    else if( sh->sps->i_poc_type == 1 && !sh->sps->b_delta_pic_order_always_zero )
-    {
-        sh->i_delta_poc[0] = bs_read_se( s );
-        if( sh->pps->b_pic_order && !sh->b_field_pic )
-        {
-            sh->i_delta_poc[1] = bs_read_se( s );
-        }
-    }
-
-    if( sh->pps->b_redundant_pic_cnt )
-    {
-        sh->i_redundant_pic_cnt = bs_read_ue( s );
-    }
-
-    if( sh->i_type == SLICE_TYPE_B )
-    {
-        sh->b_direct_spatial_mv_pred = bs_read1( s );
-    }
-
-    if( sh->i_type == SLICE_TYPE_P || sh->i_type == SLICE_TYPE_SP || sh->i_type == SLICE_TYPE_B )
-    {
-        sh->b_num_ref_idx_override = bs_read1( s );
-
-        sh->i_num_ref_idx_l0_active = sh->pps->i_num_ref_idx_l0_active; /* default */
-        sh->i_num_ref_idx_l1_active = sh->pps->i_num_ref_idx_l1_active; /* default */
-
-        if( sh->b_num_ref_idx_override )
-        {
-            sh->i_num_ref_idx_l0_active = bs_read_ue( s ) + 1;
-            if( sh->i_type == SLICE_TYPE_B )
-            {
-                sh->i_num_ref_idx_l1_active = bs_read_ue( s ) + 1;
-            }
-        }
-    }
-
-    return bs_eof( s ) ? -1 : 0;
-}
-
-static int x264_slice_header_part2_read( bs_t *s, x264_slice_header_t *sh )
-{
-    if( sh->pps->b_cabac && sh->i_type != SLICE_TYPE_I && sh->i_type != SLICE_TYPE_SI )
-    {
-        sh->i_cabac_init_idc = bs_read_ue( s );
-    }
-    sh->i_qp_delta = bs_read_se( s );
-
-    if( sh->i_type == SLICE_TYPE_SI || sh->i_type == SLICE_TYPE_SP )
-    {
-        if( sh->i_type == SLICE_TYPE_SP )
-        {
-            sh->b_sp_for_swidth = bs_read1( s );
-        }
-        sh->i_qs_delta = bs_read_se( s );
-    }
-
-    if( sh->pps->b_deblocking_filter_control )
-    {
-        sh->i_disable_deblocking_filter_idc = bs_read_ue( s );
-        if( sh->i_disable_deblocking_filter_idc != 1 )
-        {
-            sh->i_alpha_c0_offset = bs_read_se( s );
-            sh->i_beta_offset = bs_read_se( s );
-        }
-    }
-    else
-    {
-        sh->i_alpha_c0_offset = 0;
-        sh->i_beta_offset = 0;
-    }
-
-    if( sh->pps->i_num_slice_groups > 1 && sh->pps->i_slice_group_map_type >= 3 && sh->pps->i_slice_group_map_type <= 5 )
-    {
-        /* FIXME */
-        return -1;
-    }
-    return 0;
-}
-
-static int x264_slice_header_ref_pic_reordering( x264_t *h, bs_t *s )
-{
-    int b_ok;
-    int i;
-
-    /* use the no more use frame */
-    h->fdec = h->freference[0];
-    h->fdec->i_poc = h->i_poc;
-
-    /* build ref list 0/1 */
-    h->i_ref0 = 0;
-    h->i_ref1 = 0;
-    for( i = 1; i < h->sps->i_num_ref_frames + 1; i++ )
-    {
-        if( h->freference[i]->i_poc >= 0 )
-        {
-            if( h->freference[i]->i_poc < h->fdec->i_poc )
-            {
-                h->fref0[h->i_ref0++] = h->freference[i];
-            }
-            else if( h->freference[i]->i_poc > h->fdec->i_poc )
-            {
-                h->fref1[h->i_ref1++] = h->freference[i];
-            }
-        }
-    }
-
-    /* Order ref0 from higher to lower poc */
-    do
-    {
-        b_ok = 1;
-        for( i = 0; i < h->i_ref0 - 1; i++ )
-        {
-            if( h->fref0[i]->i_poc < h->fref0[i+1]->i_poc )
-            {
-                x264_frame_t *tmp = h->fref0[i+1];
-
-                h->fref0[i+1] = h->fref0[i];
-                h->fref0[i] = tmp;
-                b_ok = 0;
-                break;
-            }
-        }
-    } while( !b_ok );
-    /* Order ref1 from lower to higher poc (bubble sort) for B-frame */
-    do
-    {
-        b_ok = 1;
-        for( i = 0; i < h->i_ref1 - 1; i++ )
-        {
-            if( h->fref1[i]->i_poc > h->fref1[i+1]->i_poc )
-            {
-                x264_frame_t *tmp = h->fref1[i+1];
-
-                h->fref1[i+1] = h->fref1[i];
-                h->fref1[i] = tmp;
-                b_ok = 0;
-                break;
-            }
-        }
-    } while( !b_ok );
-
-    if( h->i_ref0 > h->pps->i_num_ref_idx_l0_active )
-    {
-        h->i_ref0 = h->pps->i_num_ref_idx_l0_active;
-    }
-    if( h->i_ref1 > h->pps->i_num_ref_idx_l1_active )
-    {
-        h->i_ref1 = h->pps->i_num_ref_idx_l1_active;
-    }
-
-    //fprintf( stderr,"POC:%d ref0=%d POC0=%d\n", h->fdec->i_poc, h->i_ref0, h->i_ref0 > 0 ? h->fref0[0]->i_poc : -1 );
-
-
-    /* Now parse the stream and change the default order */
-    if( h->sh.i_type != SLICE_TYPE_I && h->sh.i_type != SLICE_TYPE_SI )
-    {
-        int b_reorder = bs_read1( s );
-
-        if( b_reorder )
-        {
-            /* FIXME */
-            return -1;
-        }
-    }
-    if( h->sh.i_type == SLICE_TYPE_B )
-    {
-        int b_reorder = bs_read1( s );
-        if( b_reorder )
-        {
-            /* FIXME */
-            return -1;
-        }
-    }
-    return 0;
-}
-
-static int x264_slice_header_pred_weight_table( x264_t *h, bs_t *s )
-{
-    return -1;
-}
-
-static int  x264_slice_header_dec_ref_pic_marking( x264_t *h, bs_t *s, int i_nal_type  )
-{
-    if( i_nal_type == NAL_SLICE_IDR )
-    {
-        int b_no_output_of_prior_pics = bs_read1( s );
-        int b_long_term_reference_flag = bs_read1( s );
-
-        /* TODO */
-        if( b_no_output_of_prior_pics )
-        {
-
-        }
-
-        if( b_long_term_reference_flag )
-        {
-
-        }
-    }
-    else
-    {
-        int b_adaptive_ref_pic_marking_mode = bs_read1( s );
-        if( b_adaptive_ref_pic_marking_mode )
-        {
-            return -1;
-        }
-    }
-    return 0;
-}
-
-/****************************************************************************
- * Decode a slice header and setup h for mb decoding.
- ****************************************************************************/
-static int x264_slice_header_decode( x264_t *h, bs_t *s, x264_nal_t *nal )
-{
-    /* read the first part of the slice */
-    if( x264_slice_header_part1_read( s, &h->sh,
-                                      h->sps_array, h->pps_array,
-                                      nal->i_type == NAL_SLICE_IDR ? 1 : 0 ) < 0 )
-    {
-        fprintf( stderr, "x264_slice_header_part1_read failed\n" );
-        return -1;
-    }
-
-    /* now reset h if needed for this frame */
-    if( h->sps != h->sh.sps || h->pps != h->sh.pps )
-    {
-        int i;
-        /* TODO */
-
-        h->sps = NULL;
-        h->pps = NULL;
-        if( h->picture->i_width != 0 && h->picture->i_height != 0 )
-        {
-            for( i = 0; i < h->sps->i_num_ref_frames + 1; i++ )
-            {
-                x264_frame_delete( h->freference[i]);
-            }
-            free( h->mb );
-        }
-
-        h->picture->i_width = 0;
-        h->picture->i_height = 0;
-    }
-
-    /* and init if needed */
-    if( h->sps == NULL || h->pps == NULL )
-    {
-        int i;
-
-        h->sps = h->sh.sps;
-        h->pps = h->sh.pps;
-
-        h->param.i_width = h->picture->i_width = 16 * h->sps->i_mb_width;
-        h->param.i_height= h->picture->i_height= 16 * h->sps->i_mb_height;
-
-        fprintf( stderr, "x264: %dx%d\n", h->picture->i_width, h->picture->i_height );
-
-        h->mb = x264_macroblocks_new( h->sps->i_mb_width, h->sps->i_mb_height );
-
-        for( i = 0; i < h->sps->i_num_ref_frames + 1; i++ )
-        {
-            h->freference[i] = x264_frame_new( h );
-            h->freference[i]->i_poc = -1;
-        }
-        h->fdec = h->freference[0];
-        h->i_ref0 = 0;
-        h->i_ref1 = 0;
-
-        h->i_poc_msb = 0;
-        h->i_poc_lsb = 0;
-        h->i_frame_offset = 0;
-        h->i_frame_num = 0;
-    }
-
-    /* calculate poc for current frame */
-    if( h->sps->i_poc_type == 0 )
-    {
-        int i_max_poc_lsb = 1 << h->sps->i_log2_max_poc_lsb;
-
-        if( h->sh.i_poc_lsb < h->i_poc_lsb && h->i_poc_lsb - h->sh.i_poc_lsb >= i_max_poc_lsb/2 )
-        {
-            h->i_poc_msb += i_max_poc_lsb;
-        }
-        else if( h->sh.i_poc_lsb > h->i_poc_lsb  && h->sh.i_poc_lsb - h->i_poc_lsb > i_max_poc_lsb/2 )
-        {
-            h->i_poc_msb -= i_max_poc_lsb;
-        }
-        h->i_poc_lsb = h->sh.i_poc_lsb;
-
-        h->i_poc = h->i_poc_msb + h->sh.i_poc_lsb;
-    }
-    else if( h->sps->i_poc_type == 1 )
-    {
-        /* FIXME */
-        return -1;
-    }
-    else
-    {
-        if( nal->i_type == NAL_SLICE_IDR )
-        {
-            h->i_frame_offset = 0;
-            h->i_poc = 0;
-        }
-        else
-        {
-            if( h->sh.i_frame_num < h->i_frame_num )
-            {
-                h->i_frame_offset += 1 << h->sps->i_log2_max_frame_num;
-            }
-            if( nal->i_ref_idc > 0 )
-            {
-                h->i_poc = 2 * ( h->i_frame_offset + h->sh.i_frame_num );
-            }
-            else
-            {
-                h->i_poc = 2 * ( h->i_frame_offset + h->sh.i_frame_num ) - 1;
-            }
-        }
-        h->i_frame_num = h->sh.i_frame_num;
-    }
-
-    fprintf( stderr, "x264: pic type=%s poc:%d\n",
-             h->sh.i_type == SLICE_TYPE_I ? "I" : (h->sh.i_type == SLICE_TYPE_P ? "P" : "B?" ),
-             h->i_poc );
-
-    if( h->sh.i_type != SLICE_TYPE_I && h->sh.i_type != SLICE_TYPE_P )
-    {
-        fprintf( stderr, "only SLICE I/P supported\n" );
-        return -1;
-    }
-
-    /* read and do the ref pic reordering */
-    if( x264_slice_header_ref_pic_reordering( h, s ) < 0 )
-    {
-        return -1;
-    }
-
-    if( ( (h->sh.i_type == SLICE_TYPE_P || h->sh.i_type == SLICE_TYPE_SP) && h->sh.pps->b_weighted_pred  ) ||
-        ( h->sh.i_type == SLICE_TYPE_B && h->sh.pps->b_weighted_bipred ) )
-    {
-        if( x264_slice_header_pred_weight_table( h, s ) < 0 )
-        {
-            return -1;
-        }
-    }
-
-    if( nal->i_ref_idc != 0 )
-    {
-        x264_slice_header_dec_ref_pic_marking( h, s, nal->i_type );
-    }
-
-    if( x264_slice_header_part2_read( s, &h->sh ) < 0 )
-    {
-        return -1;
-    }
-
-    return 0;
-}
-
-static int x264_slice_data_decode( x264_t *h, bs_t *s )
-{
-    int mb_xy = h->sh.i_first_mb;
-    int i_ret = 0;
-
-    if( h->pps->b_cabac )
-    {
-        /* TODO: alignement and cabac init */
-    }
-
-    /* FIXME field decoding */
-    for( ;; )
-    {
-        x264_mb_context_t context;
-        x264_macroblock_t *mb;
-
-        if( mb_xy >= h->sps->i_mb_width * h->sps->i_mb_height )
-        {
-            break;
-        }
-
-        mb = &h->mb[mb_xy];
-
-        /* load neighbour */
-        x264_macroblock_context_load( h, mb, &context );
-
-
-        if( h->pps->b_cabac )
-        {
-            if( h->sh.i_type != SLICE_TYPE_I && h->sh.i_type != SLICE_TYPE_SI )
-            {
-                /* TODO */
-            }
-            i_ret = x264_macroblock_read_cabac( h, s, mb );
-        }
-        else
-        {
-            if( h->sh.i_type != SLICE_TYPE_I && h->sh.i_type != SLICE_TYPE_SI )
-            {
-                int i_skip = bs_read_ue( s );
-
-                while( i_skip > 0 )
-                {
-                    x264_macroblock_decode_skip( h, mb );
-
-                    /* next macroblock */
-                    mb_xy++;
-                    if( mb_xy >= h->sps->i_mb_width * h->sps->i_mb_height )
-                    {
-                        break;
-                    }
-                    mb++;
-
-                    /* load neighbour */
-                    x264_macroblock_context_load( h, mb, &context );
-
-                    i_skip--;
-                }
-                if( mb_xy >= h->sps->i_mb_width * h->sps->i_mb_height )
-                {
-                    break;
-                }
-            }
-            i_ret = x264_macroblock_read_cavlc( h, s, mb );
-        }
-
-        if( i_ret < 0 )
-        {
-            fprintf( stderr, "x264_macroblock_read failed [%d,%d]\n", mb->i_mb_x, mb->i_mb_y );
-            break;
-        }
-
-        if( x264_macroblock_decode( h, mb ) < 0 )
-        {
-            fprintf( stderr, "x264_macroblock_decode failed\n" );
-            /* try to do some error correction ;) */
-        }
-
-        mb_xy++;
-    }
-
-    if( i_ret >= 0 )
-    {
-        int i;
-
-        /* expand border for frame reference TODO avoid it when using b-frame */
-        x264_frame_expand_border( h->fdec );
-
-        /* apply deblocking filter to the current decoded picture */
-        if( !h->pps->b_deblocking_filter_control || h->sh.i_disable_deblocking_filter_idc != 1 )
-        {
-            x264_frame_deblocking_filter( h, h->sh.i_type );
-        }
-
-#if 0
-        /* expand border for frame reference TODO avoid it when using b-frame */
-        x264_frame_expand_border( h->fdec );
-#endif
-
-        h->picture->i_plane = h->fdec->i_plane;
-        for( i = 0; i < h->picture->i_plane; i++ )
-        {
-            h->picture->i_stride[i] = h->fdec->i_stride[i];
-            h->picture->plane[i]    = h->fdec->plane[i];
-        }
-
-        /* move frame in the buffer FIXME won't work for B-frame */
-        h->fdec = h->freference[h->sps->i_num_ref_frames];
-        for( i = h->sps->i_num_ref_frames; i > 0; i-- )
-        {
-            h->freference[i] = h->freference[i-1];
-        }
-        h->freference[0] = h->fdec;
-    }
-
-    return i_ret;
-}
-
-/****************************************************************************
- *
- ******************************* x264 libs **********************************
- *
- ****************************************************************************/
-
-/****************************************************************************
- * x264_decoder_open:
- ****************************************************************************/
-x264_t *x264_decoder_open   ( x264_param_t *param )
-{
-    x264_t *h = x264_malloc( sizeof( x264_t ) );
-    int i;
-
-    memcpy( &h->param, param, sizeof( x264_param_t ) );
-
-    h->cpu = param->cpu;
-
-    /* no SPS and PPS active yet */
-    h->sps = NULL;
-    h->pps = NULL;
-
-    for( i = 0; i < 32; i++ )
-    {
-        h->sps_array[i].i_id = -1;  /* invalidate it */
-    }
-    for( i = 0; i < 256; i++ )
-    {
-        h->pps_array[i].i_id = -1;  /* invalidate it */
-    }
-
-    h->picture = x264_malloc( sizeof( x264_picture_t ) );
-    h->picture->i_width = 0;
-    h->picture->i_height= 0;
-
-    /* init predict_XxX */
-    x264_predict_16x16_init( h->cpu, h->predict_16x16 );
-    x264_predict_8x8_init( h->cpu, h->predict_8x8 );
-    x264_predict_4x4_init( h->cpu, h->predict_4x4 );
-
-    x264_pixel_init( h->cpu, &h->pixf );
-    x264_dct_init( h->cpu, &h->dctf );
-
-    x264_mc_init( h->cpu, h->mc );
-
-    /* create the vlc table (we could remove it from x264_t but it will need
-     * to introduce a x264_init() for global librarie) */
-    for( i = 0; i < 5; i++ )
-    {
-        /* max 2 step */
-        h->x264_coeff_token_lookup[i] = x264_vlc_table_lookup_new( x264_coeff_token[i], 17*4, 4 );
-    }
-    /* max 2 step */
-    h->x264_level_prefix_lookup = x264_vlc_table_lookup_new( x264_level_prefix, 16, 8 );
-
-    for( i = 0; i < 15; i++ )
-    {
-        /* max 1 step */
-        h->x264_total_zeros_lookup[i] = x264_vlc_table_lookup_new( x264_total_zeros[i], 16, 9 );
-    }
-    for( i = 0;i < 3; i++ )
-    {
-        /* max 1 step */
-        h->x264_total_zeros_dc_lookup[i] = x264_vlc_table_lookup_new( x264_total_zeros_dc[i], 4, 3 );
-    }
-    for( i = 0;i < 7; i++ )
-    {
-        /* max 2 step */
-        h->x264_run_before_lookup[i] = x264_vlc_table_lookup_new( x264_run_before[i], 15, 6 );
-    }
-
-    return h;
-}
-
-/****************************************************************************
- * x264_decoder_decode: decode one nal unit
- ****************************************************************************/
-int     x264_decoder_decode( x264_t *h,
-                             x264_picture_t **pp_pic, x264_nal_t *nal )
-{
-    int i_ret = 0;
-    bs_t bs;
-
-    /* no picture */
-    *pp_pic = NULL;
-
-    /* init bitstream reader */
-    bs_init( &bs, nal->p_payload, nal->i_payload );
-
-    switch( nal->i_type )
-    {
-        case NAL_SPS:
-            if( ( i_ret = x264_sps_read( &bs, h->sps_array ) ) < 0 )
-            {
-                fprintf( stderr, "x264: x264_sps_read failed\n" );
-            }
-            break;
-
-        case NAL_PPS:
-            if( ( i_ret = x264_pps_read( &bs, h->pps_array ) ) < 0 )
-            {
-                fprintf( stderr, "x264: x264_pps_read failed\n" );
-            }
-            break;
-
-        case NAL_SLICE_IDR:
-            fprintf( stderr, "x264: NAL_SLICE_IDR\n" );
-            x264_slice_idr( h );
-
-        case NAL_SLICE:
-            if( ( i_ret = x264_slice_header_decode( h, &bs, nal ) ) < 0 )
-            {
-                fprintf( stderr, "x264: x264_slice_header_decode failed\n" );
-            }
-            if( h->sh.i_redundant_pic_cnt == 0 && i_ret == 0 )
-            {
-                if( ( i_ret = x264_slice_data_decode( h, &bs ) ) < 0 )
-                {
-                    fprintf( stderr, "x264: x264_slice_data_decode failed\n" );
-                }
-                else
-                {
-                    *pp_pic = h->picture;
-                }
-            }
-            break;
-
-        case NAL_SLICE_DPA:
-        case NAL_SLICE_DPB:
-        case NAL_SLICE_DPC:
-            fprintf( stderr, "partitioned stream unsupported\n" );
-            i_ret = -1;
-            break;
-
-        case NAL_SEI:
-        default:
-            break;
-    }
-
-    /* restore CPU state (before using float again) */
-    x264_cpu_restore( h->cpu );
-
-    return i_ret;
-}
-
-/****************************************************************************
- * x264_decoder_close:
- ****************************************************************************/
-void    x264_decoder_close  ( x264_t *h )
-{
-    int i;
-
-    if( h->picture->i_width != 0 && h->picture->i_height != 0 )
-    {
-        for( i = 0; i < h->sps->i_num_ref_frames + 1; i++ )
-        {
-            x264_frame_delete( h->freference[i]);
-        }
-        x264_free( h->mb );
-    }
-
-    /* free vlc table */
-    for( i = 0; i < 5; i++ )
-    {
-        x264_vlc_table_lookup_delete( h->x264_coeff_token_lookup[i] );
-    }
-    x264_vlc_table_lookup_delete( h->x264_level_prefix_lookup );
-
-    for( i = 0; i < 15; i++ )
-    {
-        x264_vlc_table_lookup_delete( h->x264_total_zeros_lookup[i] );
-    }
-    for( i = 0;i < 3; i++ )
-    {
-        x264_vlc_table_lookup_delete( h->x264_total_zeros_dc_lookup[i] );
-    }
-    for( i = 0;i < 7; i++ )
-    {
-        x264_vlc_table_lookup_delete( h->x264_run_before_lookup[i] );
-    }
-
-    x264_free( h->picture );
-    x264_free( h );
-}
-
diff --git a/decoder/macroblock.c b/decoder/macroblock.c
deleted file mode 100644 (file)
index 7ab7375..0000000
+++ /dev/null
@@ -1,1097 +0,0 @@
-/*****************************************************************************
- * macroblock.c: h264 decoder library
- *****************************************************************************
- * Copyright (C) 2003 Laurent Aimar
- * $Id: macroblock.c,v 1.1 2004/06/03 19:27:07 fenrir Exp $
- *
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-
-#include "common/common.h"
-#include "common/vlc.h"
-#include "vlc.h"
-#include "macroblock.h"
-
-static const uint8_t block_idx_x[16] =
-{
-    0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, 3
-};
-static const uint8_t block_idx_y[16] =
-{
-    0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3
-};
-static const uint8_t block_idx_xy[4][4] =
-{
-    { 0, 2, 8,  10},
-    { 1, 3, 9,  11},
-    { 4, 6, 12, 14},
-    { 5, 7, 13, 15}
-};
-
-static const int golomb_to_intra4x4_cbp[48]=
-{
-    47, 31, 15,  0, 23, 27, 29, 30,  7, 11, 13, 14, 39, 43, 45, 46,
-    16,  3,  5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44,  1,  2,  4,
-     8, 17, 18, 20, 24,  6,  9, 22, 25, 32, 33, 34, 36, 40, 38, 41
-};
-static const int golomb_to_inter_cbp[48]=
-{
-     0, 16,  1,  2,  4,  8, 32,  3,  5, 10, 12, 15, 47,  7, 11, 13,
-    14,  6,  9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46,
-    17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41
-};
-
-static const int i_chroma_qp_table[52] =
-{
-     0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
-    10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
-    20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
-    29, 30, 31, 32, 32, 33, 34, 34, 35, 35,
-    36, 36, 37, 37, 37, 38, 38, 38, 39, 39,
-    39, 39
-};
-
-
-void x264_mb_partition_ref_set( x264_macroblock_t *mb, int i_list, int i_part, int i_ref )
-{
-    int x,  y;
-    int w,  h;
-    int dx, dy;
-
-    x264_mb_partition_getxy( mb, i_part, 0, &x, &y );
-    if( mb->i_partition == D_16x16 )
-    {
-        w = 4; h = 4;
-    }
-    else if( mb->i_partition == D_16x8 )
-    {
-        w = 4; h = 2;
-    }
-    else if( mb->i_partition == D_8x16 )
-    {
-        w = 2; h = 4;
-    }
-    else
-    {
-        /* D_8x8 */
-        w = 2; h = 2;
-    }
-
-    for( dx = 0; dx < w; dx++ )
-    {
-        for( dy = 0; dy < h; dy++ )
-        {
-            mb->partition[x+dx][y+dy].i_ref[i_list] = i_ref;
-        }
-    }
-}
-
-void x264_mb_partition_mv_set( x264_macroblock_t *mb, int i_list, int i_part, int i_sub, int mv[2] )
-{
-    int x,  y;
-    int w,  h;
-    int dx, dy;
-
-    x264_mb_partition_getxy( mb, i_part, i_sub, &x, &y );
-    x264_mb_partition_size ( mb, i_part, i_sub, &w, &h );
-
-    for( dx = 0; dx < w; dx++ )
-    {
-        for( dy = 0; dy < h; dy++ )
-        {
-            mb->partition[x+dx][y+dy].mv[i_list][0] = mv[0];
-            mb->partition[x+dx][y+dy].mv[i_list][1] = mv[1];
-        }
-    }
-}
-
-
-int x264_macroblock_read_cabac( x264_t *h, bs_t *s, x264_macroblock_t *mb )
-{
-    return -1;
-}
-
-static int x264_macroblock_decode_ipcm( x264_t *h, bs_t *s, x264_macroblock_t *mb )
-{
-    /* TODO */
-    return -1;
-}
-
-
-#define BLOCK_INDEX_CHROMA_DC   (-1)
-#define BLOCK_INDEX_LUMA_DC     (-2)
-
-static int bs_read_vlc( bs_t *s, x264_vlc_table_t *table )
-{
-    int i_nb_bits;
-    int i_value = 0;
-    int i_bits;
-    int i_index;
-    int i_level = 0;
-
-    i_index = bs_show( s, table->i_lookup_bits );
-    if( i_index >= table->i_lookup )
-    {
-        return( -1 );
-    }
-    i_value = table->lookup[i_index].i_value;
-    i_bits  = table->lookup[i_index].i_size;
-
-    while( i_bits < 0 )
-    {
-        i_level++;
-        if( i_level > 5 )
-        {
-            return( -1 );        // FIXME what to do ?
-        }
-        bs_skip( s, table->i_lookup_bits );
-        i_nb_bits = -i_bits;
-
-        i_index = bs_show( s, i_nb_bits ) + i_value;
-        if( i_index >= table->i_lookup )
-        {
-            return( -1 );
-        }
-        i_value = table->lookup[i_index].i_value;
-        i_bits  = table->lookup[i_index].i_size;
-    }
-    bs_skip( s, i_bits );
-
-    return( i_value );
-}
-
-static int block_residual_read_cavlc( x264_t *h, bs_t *s, x264_macroblock_t *mb,
-                                      int i_idx, int *l, int i_count )
-{
-    int i;
-    int level[16], run[16];
-    int i_coeff;
-
-    int i_total, i_trailing;
-    int i_suffix_length;
-    int i_zero_left;
-
-    for( i = 0; i < i_count; i++ )
-    {
-        l[i] = 0;
-    }
-
-    /* total/trailing */
-    if( i_idx == BLOCK_INDEX_CHROMA_DC )
-    {
-        int i_tt;
-
-        if( ( i_tt = bs_read_vlc( s, h->x264_coeff_token_lookup[4] )) < 0 )
-        {
-            return -1;
-        }
-
-        i_total = i_tt / 4;
-        i_trailing = i_tt % 4;
-    }
-    else
-    {
-        /* x264_mb_predict_non_zero_code return 0 <-> (16+16+1)>>1 = 16 */
-        static const int ct_index[17] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,3 };
-        int nC;
-        int i_tt;
-
-        if( i_idx == BLOCK_INDEX_LUMA_DC )
-        {
-            nC = x264_mb_predict_non_zero_code( h, mb, 0 );
-        }
-        else
-        {
-            nC = x264_mb_predict_non_zero_code( h, mb, i_idx );
-        }
-
-        if( ( i_tt = bs_read_vlc( s, h->x264_coeff_token_lookup[ct_index[nC]] ) ) < 0 )
-        {
-            return -1;
-        }
-
-        i_total = i_tt / 4;
-        i_trailing = i_tt % 4;
-    }
-
-    if( i_idx >= 0 )
-    {
-        mb->block[i_idx].i_non_zero_count = i_total;
-    }
-
-    if( i_total <= 0 )
-    {
-        return 0;
-    }
-
-    i_suffix_length = i_total > 10 && i_trailing < 3 ? 1 : 0;
-
-    for( i = 0; i < i_trailing; i++ )
-    {
-        level[i] = 1 - 2 * bs_read1( s );
-    }
-
-    for( ; i < i_total; i++ )
-    {
-        int i_prefix;
-        int i_level_code;
-
-        i_prefix = bs_read_vlc( s, h->x264_level_prefix_lookup );
-
-        if( i_prefix == -1 )
-        {
-            return -1;
-        }
-        else if( i_prefix < 14 )
-        {
-            if( i_suffix_length > 0 )
-            {
-                i_level_code = (i_prefix << i_suffix_length) + bs_read( s, i_suffix_length );
-            }
-            else
-            {
-                i_level_code = i_prefix;
-            }
-        }
-        else if( i_prefix == 14 )
-        {
-            if( i_suffix_length > 0 )
-            {
-                i_level_code = (i_prefix << i_suffix_length) + bs_read( s, i_suffix_length );
-            }
-            else
-            {
-                i_level_code = i_prefix + bs_read( s, 4 );
-            }
-        }
-        else /* if( i_prefix == 15 ) */
-        {
-            i_level_code = (i_prefix << i_suffix_length) + bs_read( s, 12 );
-            if( i_suffix_length == 0 )
-            {
-                i_level_code += 15;
-            }
-        }
-        if( i == i_trailing && i_trailing < 3 )
-        {
-            i_level_code += 2;
-        }
-        /* Optimise */
-        level[i] = i_level_code&0x01 ? -((i_level_code+1)/2) : (i_level_code+2)/2;
-
-        if( i_suffix_length == 0 )
-        {
-            i_suffix_length++;
-        }
-        if( abs( level[i] ) > ( 3 << ( i_suffix_length - 1 ) ) && i_suffix_length < 6 )
-        {
-            i_suffix_length++;
-        }
-    }
-
-    if( i_total < i_count )
-    {
-        if( i_idx == BLOCK_INDEX_CHROMA_DC )
-        {
-            i_zero_left = bs_read_vlc( s, h->x264_total_zeros_dc_lookup[i_total-1] );
-        }
-        else
-        {
-            i_zero_left = bs_read_vlc( s, h->x264_total_zeros_lookup[i_total-1] );
-        }
-        if( i_zero_left < 0 )
-        {
-            return -1;
-        }
-    }
-    else
-    {
-        i_zero_left = 0;
-    }
-
-    for( i = 0; i < i_total - 1; i++ )
-    {
-        if( i_zero_left <= 0 )
-        {
-            break;
-        }
-        run[i] = bs_read_vlc( s, h->x264_run_before_lookup[X264_MIN( i_zero_left - 1, 6 )] );
-
-        if( run[i] < 0 )
-        {
-            return -1;
-        }
-        i_zero_left -= run[i];
-    }
-    if( i_zero_left < 0 )
-    {
-        return -1;
-    }
-
-    for( ; i < i_total - 1; i++ )
-    {
-        run[i] = 0;
-    }
-    run[i_total-1] = i_zero_left;
-
-    i_coeff = -1;
-    for( i = i_total - 1; i >= 0; i-- )
-    {
-        i_coeff += run[i] + 1;
-        l[i_coeff] = level[i];
-    }
-
-    return 0;
-}
-
-static inline void array_zero_set( int *l, int i_count )
-{
-    int i;
-
-    for( i = 0; i < i_count; i++ )
-    {
-        l[i] = 0;
-    }
-}
-
-int x264_macroblock_read_cavlc( x264_t *h, bs_t *s, x264_macroblock_t *mb )
-{
-    int i_mb_i_offset;
-    int i_mb_p_offset;
-    int b_sub_ref0 = 0;
-    int i_type;
-    int i;
-
-    /* read the mb type */
-    switch( h->sh.i_type )
-    {
-        case SLICE_TYPE_I:
-            i_mb_p_offset = 0;  /* shut up gcc */
-            i_mb_i_offset = 0;
-            break;
-        case SLICE_TYPE_P:
-            i_mb_p_offset = 0;
-            i_mb_i_offset = 5;
-            break;
-        case SLICE_TYPE_B:
-            i_mb_p_offset = 23;
-            i_mb_i_offset = 23 + 5;
-            break;
-        default:
-            fprintf( stderr, "internal error or slice unsupported\n" );
-            return -1;
-    }
-
-    i_type = bs_read_ue( s );
-
-    if( i_type < i_mb_i_offset )
-    {
-        if( i_type < i_mb_p_offset )
-        {
-            fprintf( stderr, "unsupported mb type(B*)\n" );
-            /* TODO for B frame */
-            return -1;
-        }
-        else
-        {
-            i_type -= i_mb_p_offset;
-
-            if( i_type == 0 )
-            {
-                mb->i_type = P_L0;
-                mb->i_partition = D_16x16;
-            }
-            else if( i_type == 1 )
-            {
-                mb->i_type = P_L0;
-                mb->i_partition = D_16x8;
-            }
-            else if( i_type == 2 )
-            {
-                mb->i_type = P_L0;
-                mb->i_partition = D_8x16;
-            }
-            else if( i_type == 3 || i_type == 4 )
-            {
-                mb->i_type = P_8x8;
-                mb->i_partition = D_8x8;
-                b_sub_ref0 = i_type == 4 ? 1 : 0;
-            }
-            else
-            {
-                fprintf( stderr, "invalid mb type\n" );
-                return -1;
-            }
-        }
-    }
-    else
-    {
-        i_type -= i_mb_i_offset;
-
-        if( i_type == 0 )
-        {
-            mb->i_type = I_4x4;
-        }
-        else if( i_type < 25 )
-        {
-            mb->i_type = I_16x16;
-
-            mb->i_intra16x16_pred_mode = (i_type - 1)%4;
-            mb->i_cbp_chroma = ( (i_type-1) / 4 )%3;
-            mb->i_cbp_luma   = ((i_type-1) / 12) ? 0x0f : 0x00;
-        }
-        else if( i_type == 25 )
-        {
-            mb->i_type = I_PCM;
-        }
-        else
-        {
-            fprintf( stderr, "invalid mb type (%d)\n", i_type );
-            return -1;
-        }
-    }
-
-    if( mb->i_type == I_PCM )
-    {
-        return x264_macroblock_decode_ipcm( h, s, mb );
-    }
-
-    if( IS_INTRA( mb->i_type ) )
-    {
-        if( mb->i_type == I_4x4 )
-        {
-            for( i = 0; i < 16; i++ )
-            {
-                int b_coded;
-
-                b_coded = bs_read1( s );
-
-                if( b_coded )
-                {
-                    mb->block[i].i_intra4x4_pred_mode = x264_mb_predict_intra4x4_mode( h, mb, i );
-                }
-                else
-                {
-                    int i_predicted_mode = x264_mb_predict_intra4x4_mode( h, mb, i );
-                    int i_mode = bs_read( s, 3 );
-
-                    if( i_mode >= i_predicted_mode )
-                    {
-                        mb->block[i].i_intra4x4_pred_mode = i_mode + 1;
-                    }
-                    else
-                    {
-                        mb->block[i].i_intra4x4_pred_mode = i_mode;
-                    }
-                }
-            }
-        }
-
-        mb->i_chroma_pred_mode = bs_read_ue( s );
-    }
-    else if( mb->i_type == P_8x8 || mb->i_type == B_8x8)
-    {
-        /* FIXME won't work for B_8x8 */
-
-        for( i = 0; i < 4; i++ )
-        {
-            int i_sub_partition;
-
-            i_sub_partition = bs_read_ue( s );
-            switch( i_sub_partition )
-            {
-                case 0:
-                    mb->i_sub_partition[i] = D_L0_8x8;
-                    break;
-                case 1:
-                    mb->i_sub_partition[i] = D_L0_8x4;
-                    break;
-                case 2:
-                    mb->i_sub_partition[i] = D_L0_4x8;
-                    break;
-                case 3:
-                    mb->i_sub_partition[i] = D_L0_4x4;
-                    break;
-                default:
-                    fprintf( stderr, "invalid i_sub_partition\n" );
-                    return -1;
-            }
-        }
-        for( i = 0; i < 4; i++ )
-        {
-            int i_ref;
-
-            i_ref = b_sub_ref0 ? 0 : bs_read_te( s, h->sh.i_num_ref_idx_l0_active - 1 );
-            x264_mb_partition_ref_set( mb, 0, i, i_ref );
-        }
-        for( i = 0; i < 4; i++ )
-        {
-            int i_sub;
-            int i_ref;
-
-            x264_mb_partition_get( mb, 0, i, 0, &i_ref, NULL, NULL );
-
-            for( i_sub = 0; i_sub < x264_mb_partition_count_table[mb->i_sub_partition[i]]; i_sub++ )
-            {
-                int mv[2];
-
-                x264_mb_predict_mv( mb, 0, i, i_sub, mv );
-                mv[0] += bs_read_se( s );
-                mv[1] += bs_read_se( s );
-
-                x264_mb_partition_mv_set( mb, 0, i, i_sub, mv );
-            }
-        }
-    }
-    else if( mb->i_type != B_DIRECT )
-    {
-        /* FIXME will work only for P block */
-
-        /* FIXME using x264_mb_partition_set/x264_mb_partition_get here are too unoptimised
-         * I should introduce ref and mv get/set */
-
-        /* Motion Vector */
-        int i_part = x264_mb_partition_count_table[mb->i_partition];
-
-        for( i = 0; i < i_part; i++ )
-        {
-            int i_ref;
-
-            i_ref = bs_read_te( s, h->sh.i_num_ref_idx_l0_active - 1 );
-
-            x264_mb_partition_ref_set( mb, 0, i, i_ref );
-        }
-
-        for( i = 0; i < i_part; i++ )
-        {
-            int mv[2];
-
-            x264_mb_predict_mv( mb, 0, i, 0, mv );
-
-            mv[0] += bs_read_se( s );
-            mv[1] += bs_read_se( s );
-
-            x264_mb_partition_mv_set( mb, 0, i, 0, mv );
-        }
-    }
-
-    if( mb->i_type != I_16x16 )
-    {
-        int i_cbp;
-
-        i_cbp = bs_read_ue( s );
-        if( i_cbp >= 48 )
-        {
-            fprintf( stderr, "invalid cbp\n" );
-            return -1;
-        }
-
-        if( mb->i_type == I_4x4 )
-        {
-            i_cbp = golomb_to_intra4x4_cbp[i_cbp];
-        }
-        else
-        {
-            i_cbp = golomb_to_inter_cbp[i_cbp];
-        }
-        mb->i_cbp_luma   = i_cbp&0x0f;
-        mb->i_cbp_chroma = i_cbp >> 4;
-    }
-
-    if( mb->i_cbp_luma > 0 || mb->i_cbp_chroma > 0 || mb->i_type == I_16x16 )
-    {
-        mb->i_qp = bs_read_se( s ) + h->pps->i_pic_init_qp + h->sh.i_qp_delta;
-
-        /* write residual */
-        if( mb->i_type == I_16x16 )
-        {
-            /* DC Luma */
-            if( block_residual_read_cavlc( h, s, mb, BLOCK_INDEX_LUMA_DC , mb->luma16x16_dc, 16 ) < 0 )
-            {
-                return -1;
-            }
-
-            if( mb->i_cbp_luma != 0 )
-            {
-                /* AC Luma */
-                for( i = 0; i < 16; i++ )
-                {
-                    if( block_residual_read_cavlc( h, s, mb, i, mb->block[i].residual_ac, 15 ) < 0 )
-                    {
-                        return -1;
-                    }
-                }
-            }
-            else
-            {
-                for( i = 0; i < 16; i++ )
-                {
-                    mb->block[i].i_non_zero_count = 0;
-                    array_zero_set( mb->block[i].residual_ac, 15 );
-                }
-            }
-        }
-        else
-        {
-            for( i = 0; i < 16; i++ )
-            {
-                if( mb->i_cbp_luma & ( 1 << ( i / 4 ) ) )
-                {
-                    if( block_residual_read_cavlc( h, s, mb, i, mb->block[i].luma4x4, 16 ) < 0 )
-                    {
-                        return -1;
-                    }
-                }
-                else
-                {
-                    mb->block[i].i_non_zero_count = 0;
-                    array_zero_set( mb->block[i].luma4x4, 16 );
-                }
-            }
-        }
-
-        if( mb->i_cbp_chroma &0x03 )    /* Chroma DC residual present */
-        {
-            if( block_residual_read_cavlc( h, s, mb, BLOCK_INDEX_CHROMA_DC, mb->chroma_dc[0], 4 ) < 0 ||
-                block_residual_read_cavlc( h, s, mb, BLOCK_INDEX_CHROMA_DC, mb->chroma_dc[1], 4 ) < 0 )
-            {
-                return -1;
-            }
-        }
-        else
-        {
-            array_zero_set( mb->chroma_dc[0], 4 );
-            array_zero_set( mb->chroma_dc[1], 4 );
-        }
-        if( mb->i_cbp_chroma&0x02 ) /* Chroma AC residual present */
-        {
-            for( i = 0; i < 8; i++ )
-            {
-                if( block_residual_read_cavlc( h, s, mb, 16 + i, mb->block[16+i].residual_ac, 15 ) < 0 )
-                {
-                    return -1;
-                }
-            }
-        }
-        else
-        {
-            for( i = 0; i < 8; i++ )
-            {
-                mb->block[16+i].i_non_zero_count = 0;
-                array_zero_set( mb->block[16+i].residual_ac, 15 );
-            }
-        }
-    }
-    else
-    {
-        mb->i_qp = h->pps->i_pic_init_qp + h->sh.i_qp_delta;
-        for( i = 0; i < 16; i++ )
-        {
-            mb->block[i].i_non_zero_count = 0;
-            array_zero_set( mb->block[i].luma4x4, 16 );
-        }
-        array_zero_set( mb->chroma_dc[0], 4 );
-        array_zero_set( mb->chroma_dc[1], 4 );
-        for( i = 0; i < 8; i++ )
-        {
-            array_zero_set( mb->block[16+i].residual_ac, 15 );
-            mb->block[16+i].i_non_zero_count = 0;
-        }
-    }
-
-    //fprintf( stderr, "mb read type=%d\n", mb->i_type );
-
-    return 0;
-}
-
-
-
-
-static int x264_mb_pred_mode16x16_valid( x264_macroblock_t *mb, int i_mode )
-{
-    if( ( mb->i_neighbour & (MB_LEFT|MB_TOP) ) == (MB_LEFT|MB_TOP) )
-    {
-        return i_mode;
-    }
-    else if( ( mb->i_neighbour & MB_LEFT ) )
-    {
-        if( i_mode == I_PRED_16x16_DC )
-        {
-            return I_PRED_16x16_DC_LEFT;
-        }
-        else if( i_mode == I_PRED_16x16_H )
-        {
-            return I_PRED_16x16_H;
-        }
-
-        fprintf( stderr, "invalid 16x16 prediction\n" );
-        return I_PRED_16x16_DC_LEFT;
-    }
-    else if( ( mb->i_neighbour & MB_TOP ) )
-    {
-        if( i_mode == I_PRED_16x16_DC )
-        {
-            return I_PRED_16x16_DC_TOP;
-        }
-        else if( i_mode == I_PRED_16x16_V )
-        {
-            return I_PRED_16x16_V;
-        }
-
-        fprintf( stderr, "invalid 16x16 prediction\n" );
-        return I_PRED_16x16_DC_TOP;
-    }
-    else
-    {
-        return I_PRED_16x16_DC_128;
-    }
-}
-
-static int x264_mb_pred_mode8x8_valid( x264_macroblock_t *mb, int i_mode )
-{
-    if( ( mb->i_neighbour & (MB_LEFT|MB_TOP) ) == (MB_LEFT|MB_TOP) )
-    {
-        return i_mode;
-    }
-    else if( ( mb->i_neighbour & MB_LEFT ) )
-    {
-        if( i_mode == I_PRED_CHROMA_DC )
-        {
-            return I_PRED_CHROMA_DC_LEFT;
-        }
-        else if( i_mode == I_PRED_CHROMA_H )
-        {
-            return I_PRED_CHROMA_H;
-        }
-
-        fprintf( stderr, "invalid 8x8 prediction\n" );
-        return I_PRED_CHROMA_DC_LEFT;
-    }
-    else if( ( mb->i_neighbour & MB_TOP ) )
-    {
-        if( i_mode == I_PRED_CHROMA_DC )
-        {
-            return I_PRED_CHROMA_DC_TOP;
-        }
-        else if( i_mode == I_PRED_CHROMA_V )
-        {
-            return I_PRED_CHROMA_V;
-        }
-
-        fprintf( stderr, "invalid 8x8 prediction\n" );
-        return I_PRED_CHROMA_DC_TOP;
-    }
-    else
-    {
-        return I_PRED_CHROMA_DC_128;
-    }
-}
-
-static int x264_mb_pred_mode4x4_valid( x264_macroblock_t *mb, int idx, int i_mode, int *pb_emu )
-{
-    int b_a, b_b, b_c;
-    static const int needmb[16] =
-    {
-        MB_LEFT|MB_TOP, MB_TOP,
-        MB_LEFT,        MB_PRIVATE,
-        MB_TOP,         MB_TOP|MB_TOPRIGHT,
-        0,              MB_PRIVATE,
-        MB_LEFT,        0,
-        MB_LEFT,        MB_PRIVATE,
-        0,              MB_PRIVATE,
-        0,              MB_PRIVATE
-    };
-    int b_emu = 0;
-
-    *pb_emu = 0;
-
-    b_a = (needmb[idx]&mb->i_neighbour&MB_LEFT) == (needmb[idx]&MB_LEFT);
-    b_b = (needmb[idx]&mb->i_neighbour&MB_TOP) == (needmb[idx]&MB_TOP);
-    b_c = (needmb[idx]&mb->i_neighbour&(MB_TOPRIGHT|MB_PRIVATE)) == (needmb[idx]&(MB_TOPRIGHT|MB_PRIVATE));
-
-    if( b_c == 0 && b_b )
-    {
-        b_emu = 1;
-        b_c = 1;
-    }
-
-    /* handle I_PRED_4x4_DC */
-    if( i_mode == I_PRED_4x4_DC )
-    {
-        if( b_a && b_b )
-        {
-            return I_PRED_4x4_DC;
-        }
-        else if( b_a )
-        {
-            return I_PRED_4x4_DC_LEFT;
-        }
-        else if( b_b )
-        {
-            return I_PRED_4x4_DC_TOP;
-        }
-        return I_PRED_4x4_DC_128;
-    }
-
-    /* handle 1 dir needed only */
-    if( ( b_a && i_mode == I_PRED_4x4_H ) ||
-        ( b_b && i_mode == I_PRED_4x4_V ) )
-    {
-        return i_mode;
-    }
-
-    /* handle b_c case (b_b always true) */
-    if( b_c && ( i_mode == I_PRED_4x4_DDL || i_mode == I_PRED_4x4_VL ) )
-    {
-        *pb_emu = b_emu;
-        return i_mode;
-    }
-
-    if( b_a && b_b )
-    {
-        /* I_PRED_4x4_DDR, I_PRED_4x4_VR, I_PRED_4x4_HD, I_PRED_4x4_HU */
-        return i_mode;
-    }
-
-    fprintf( stderr, "invalid 4x4 predict mode(%d, mb:%x-%x idx:%d\n", i_mode, mb->i_mb_x, mb->i_mb_y, idx );
-    return I_PRED_CHROMA_DC_128;    /* unefficient */
-}
-
-/****************************************************************************
- * UnScan functions
- ****************************************************************************/
-static const int scan_zigzag_x[16]={0, 1, 0, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 3, 2, 3};
-static const int scan_zigzag_y[16]={0, 0, 1, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 2, 3, 3};
-
-static inline void unscan_zigzag_4x4full( int16_t dct[4][4], int level[16] )
-{
-    int i;
-
-    for( i = 0; i < 16; i++ )
-    {
-        dct[scan_zigzag_y[i]][scan_zigzag_x[i]] = level[i];
-    }
-}
-static inline void unscan_zigzag_4x4( int16_t dct[4][4], int level[15] )
-{
-    int i;
-
-    for( i = 1; i < 16; i++ )
-    {
-        dct[scan_zigzag_y[i]][scan_zigzag_x[i]] = level[i - 1];
-    }
-}
-
-static inline void unscan_zigzag_2x2_dc( int16_t dct[2][2], int level[4] )
-{
-    dct[0][0] = level[0];
-    dct[0][1] = level[1];
-    dct[1][0] = level[2];
-    dct[1][1] = level[3];
-}
-
-
-int x264_macroblock_decode( x264_t *h, x264_macroblock_t *mb )
-{
-    x264_mb_context_t *ctx = mb->context;
-
-    int i_qscale;
-    int ch;
-    int i;
-
-    if( !IS_INTRA(mb->i_type ) )
-    {
-        /* Motion compensation */
-        x264_mb_mc( h, mb );
-    }
-
-    /* luma */
-    i_qscale = mb->i_qp;
-    if( mb->i_type == I_16x16 )
-    {
-        int     i_mode = x264_mb_pred_mode16x16_valid( mb, mb->i_intra16x16_pred_mode );
-        int16_t luma[16][4][4];
-        int16_t dct4x4[16+1][4][4];
-
-
-        /* do the right prediction */
-        h->predict_16x16[i_mode]( ctx->p_fdec[0], ctx->i_fdec[0] );
-
-        /* get dc coeffs */
-        unscan_zigzag_4x4full( dct4x4[0], mb->luma16x16_dc );
-        h->dctf.idct4x4dc( dct4x4[0], dct4x4[0] );
-        x264_mb_dequant_4x4_dc( dct4x4[0], i_qscale );
-
-        /* decode the 16x16 macroblock */
-        for( i = 0; i < 16; i++ )
-        {
-            unscan_zigzag_4x4( dct4x4[1+i], mb->block[i].residual_ac );
-            x264_mb_dequant_4x4( dct4x4[1+i], i_qscale );
-
-            /* copy dc coeff */
-            dct4x4[1+i][0][0] = dct4x4[0][block_idx_y[i]][block_idx_x[i]];
-
-            h->dctf.idct4x4( luma[i], dct4x4[i+1] );
-        }
-        /* put pixels to fdec */
-        h->pixf.add16x16( ctx->p_fdec[0], ctx->i_fdec[0], luma );
-    }
-    else if( mb->i_type == I_4x4 )
-    {
-        for( i = 0; i < 16; i++ )
-        {
-            int16_t luma[4][4];
-            int16_t dct4x4[4][4];
-
-            uint8_t *p_dst_by;
-            int     i_mode;
-            int     b_emu;
-
-            /* Do the right prediction */
-            p_dst_by = ctx->p_fdec[0] + 4 * block_idx_x[i] + 4 * block_idx_y[i] * ctx->i_fdec[0];
-            i_mode   = x264_mb_pred_mode4x4_valid( mb, i, mb->block[i].i_intra4x4_pred_mode, &b_emu );
-            if( b_emu )
-            {
-                fprintf( stderr, "mmmh b_emu\n" );
-                memset( &p_dst_by[4], p_dst_by[3], 4 );
-            }
-            h->predict_4x4[i_mode]( p_dst_by, ctx->i_fdec[0] );
-
-            if( mb->block[i].i_non_zero_count > 0 )
-            {
-                /* decode one 4x4 block */
-                unscan_zigzag_4x4full( dct4x4, mb->block[i].luma4x4 );
-
-                x264_mb_dequant_4x4( dct4x4, i_qscale );
-
-                h->dctf.idct4x4( luma, dct4x4 );
-
-                h->pixf.add4x4( p_dst_by, ctx->i_fdec[0], luma );
-            }
-        }
-    }
-    else /* Inter mb */
-    {
-        for( i = 0; i < 16; i++ )
-        {
-            uint8_t *p_dst_by;
-            int16_t luma[4][4];
-            int16_t dct4x4[4][4];
-
-            if( mb->block[i].i_non_zero_count > 0 )
-            {
-                unscan_zigzag_4x4full( dct4x4, mb->block[i].luma4x4 );
-                x264_mb_dequant_4x4( dct4x4, i_qscale );
-
-                h->dctf.idct4x4( luma, dct4x4 );
-
-                p_dst_by = ctx->p_fdec[0] + 4 * block_idx_x[i] + 4 * block_idx_y[i] * ctx->i_fdec[0];
-                h->pixf.add4x4( p_dst_by, ctx->i_fdec[0], luma );
-            }
-        }
-    }
-
-    /* chroma */
-    i_qscale = i_chroma_qp_table[x264_clip3( i_qscale + h->pps->i_chroma_qp_index_offset, 0, 51 )];
-    if( IS_INTRA( mb->i_type ) )
-    {
-        int i_mode = x264_mb_pred_mode8x8_valid( mb, mb->i_chroma_pred_mode );
-        /* do the right prediction */
-        h->predict_8x8[i_mode]( ctx->p_fdec[1], ctx->i_fdec[1] );
-        h->predict_8x8[i_mode]( ctx->p_fdec[2], ctx->i_fdec[2] );
-    }
-
-    if( mb->i_cbp_chroma != 0 )
-    {
-        for( ch = 0; ch < 2; ch++ )
-        {
-            int16_t chroma[4][4][4];
-            int16_t dct2x2[2][2];
-            int16_t dct4x4[4][4][4];
-
-            /* get dc chroma */
-            unscan_zigzag_2x2_dc( dct2x2, mb->chroma_dc[ch] );
-            h->dctf.idct2x2dc( dct2x2, dct2x2 );
-            x264_mb_dequant_2x2_dc( dct2x2, i_qscale );
-
-            for( i = 0; i < 4; i++ )
-            {
-                unscan_zigzag_4x4( dct4x4[i], mb->block[16+i+ch*4].residual_ac );
-                x264_mb_dequant_4x4( dct4x4[i], i_qscale );
-
-                /* copy dc coeff */
-                dct4x4[i][0][0] = dct2x2[block_idx_y[i]][block_idx_x[i]];
-
-                h->dctf.idct4x4( chroma[i], dct4x4[i] );
-            }
-            h->pixf.add8x8( ctx->p_fdec[1+ch], ctx->i_fdec[1+ch], chroma );
-        }
-    }
-
-    return 0;
-}
-
-void x264_macroblock_decode_skip( x264_t *h, x264_macroblock_t *mb )
-{
-    int i;
-    int x, y;
-    int mv[2];
-
-    /* decode it as a 16x16 with no luma/chroma */
-    mb->i_type = P_L0;
-    mb->i_partition = D_16x16;
-    mb->i_cbp_luma = 0;
-    mb->i_cbp_chroma = 0;
-    for( i = 0; i < 16 + 8; i++ )
-    {
-        mb->block[i].i_non_zero_count = 0;
-    }
-    for( i = 0; i < 16; i++ )
-    {
-        array_zero_set( mb->block[i].luma4x4, 16 );
-    }
-    array_zero_set( mb->chroma_dc[0], 4 );
-    array_zero_set( mb->chroma_dc[1], 4 );
-    for( i = 0; i < 8; i++ )
-    {
-        array_zero_set( mb->block[16+i].residual_ac, 15 );
-    }
-
-    /* set ref0 */
-    for( x = 0; x < 4; x++ )
-    {
-        for( y = 0; y < 4; y++ )
-        {
-            mb->partition[x][y].i_ref[0] = 0;
-        }
-    }
-    /* get mv */
-    x264_mb_predict_mv_pskip( mb, mv );
-
-    x264_mb_partition_mv_set( mb, 0, 0, 0, mv );
-
-    /* Motion compensation */
-    x264_mb_mc( h, mb );
-
-    mb->i_type = P_SKIP;
-}
-
diff --git a/decoder/macroblock.h b/decoder/macroblock.h
deleted file mode 100644 (file)
index 96b5d2e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*****************************************************************************
- * macroblock.h: h264 decoder library
- *****************************************************************************
- * Copyright (C) 2003 Laurent Aimar
- * $Id: macroblock.h,v 1.1 2004/06/03 19:27:07 fenrir Exp $
- *
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#ifndef _DECODER_MACROBLOCK_H
-#define _DECODER_MACROBLOCK_H 1
-
-int  x264_macroblock_read_cabac( x264_t *h, bs_t *s, x264_macroblock_t *mb );
-int  x264_macroblock_read_cavlc( x264_t *h, bs_t *s, x264_macroblock_t *mb );
-
-int  x264_macroblock_decode( x264_t *h, x264_macroblock_t *mb );
-void x264_macroblock_decode_skip( x264_t *h, x264_macroblock_t *mb );
-
-#endif
-
diff --git a/decoder/set.c b/decoder/set.c
deleted file mode 100644 (file)
index 10e0796..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/*****************************************************************************
- * x264: h264 decoder
- *****************************************************************************
- * Copyright (C) 2003 Laurent Aimar
- * $Id: set.c,v 1.1 2004/06/03 19:27:07 fenrir Exp $
- *
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-
-#include "common/common.h"
-#include "set.h"
-
-/* return -1 if invalid, else the id */
-int x264_sps_read( bs_t *s, x264_sps_t sps_array[32] )
-{
-    x264_sps_t *sps;
-
-    int i_profile_idc;
-    int i_level_idc;
-
-    int b_constraint_set0;
-    int b_constraint_set1;
-    int b_constraint_set2;
-
-    int id;
-
-    i_profile_idc     = bs_read( s, 8 );
-    b_constraint_set0 = bs_read( s, 1 );
-    b_constraint_set1 = bs_read( s, 1 );
-    b_constraint_set2 = bs_read( s, 1 );
-
-    bs_skip( s, 5 );    /* reserved */
-    i_level_idc       = bs_read( s, 8 );
-
-
-    id = bs_read_ue( s );
-    if( bs_eof( s ) || id >= 32 )
-    {
-        /* the sps is invalid, no need to corrupt sps_array[0] */
-        return -1;
-    }
-
-    sps = &sps_array[id];
-    sps->i_id = id;
-
-    /* put pack parsed value */
-    sps->i_profile_idc     = i_profile_idc;
-    sps->i_level_idc       = i_level_idc;
-    sps->b_constraint_set0 = b_constraint_set0;
-    sps->b_constraint_set1 = b_constraint_set1;
-    sps->b_constraint_set2 = b_constraint_set2;
-
-    sps->i_log2_max_frame_num = bs_read_ue( s ) + 4;
-
-    sps->i_poc_type = bs_read_ue( s );
-    if( sps->i_poc_type == 0 )
-    {
-        sps->i_log2_max_poc_lsb = bs_read_ue( s ) + 4;
-    }
-    else if( sps->i_poc_type == 1 )
-    {
-        int i;
-        sps->b_delta_pic_order_always_zero = bs_read( s, 1 );
-        sps->i_offset_for_non_ref_pic = bs_read_se( s );
-        sps->i_offset_for_top_to_bottom_field = bs_read_se( s );
-        sps->i_num_ref_frames_in_poc_cycle = bs_read_ue( s );
-        if( sps->i_num_ref_frames_in_poc_cycle > 256 )
-        {
-            /* FIXME what to do */
-            sps->i_num_ref_frames_in_poc_cycle = 256;
-        }
-        for( i = 0; i < sps->i_num_ref_frames_in_poc_cycle; i++ )
-        {
-            sps->i_offset_for_ref_frame[i] = bs_read_se( s );
-        }
-    }
-    else if( sps->i_poc_type > 2 )
-    {
-        goto error;
-    }
-
-    sps->i_num_ref_frames = bs_read_ue( s );
-    sps->b_gaps_in_frame_num_value_allowed = bs_read( s, 1 );
-    sps->i_mb_width = bs_read_ue( s ) + 1;
-    sps->i_mb_height= bs_read_ue( s ) + 1;
-    sps->b_frame_mbs_only = bs_read( s, 1 );
-    if( !sps->b_frame_mbs_only )
-    {
-        sps->b_mb_adaptive_frame_field = bs_read( s, 1 );
-    }
-    else
-    {
-        sps->b_mb_adaptive_frame_field = 0;
-    }
-    sps->b_direct8x8_inference = bs_read( s, 1 );
-
-    sps->b_crop = bs_read( s, 1 );
-    if( sps->b_crop )
-    {
-        sps->crop.i_left  = bs_read_ue( s );
-        sps->crop.i_right = bs_read_ue( s );
-        sps->crop.i_top   = bs_read_ue( s );
-        sps->crop.i_bottom= bs_read_ue( s );
-    }
-    else
-    {
-        sps->crop.i_left  = 0;
-        sps->crop.i_right = 0;
-        sps->crop.i_top   = 0;
-        sps->crop.i_bottom= 0;
-    }
-
-    sps->b_vui = bs_read( s, 1 );
-    if( sps->b_vui )
-    {
-        /* FIXME */
-    }
-    else
-    {
-
-    }
-
-    if( bs_eof( s ) )
-    {
-        /* no rbsp trailing */
-        fprintf( stderr, "incomplete SPS\n" );
-        goto error;
-    }
-
-    fprintf( stderr, "x264_sps_read: sps:0x%x profile:%d/%d poc:%d ref:%d %xx%d crop:%d-%d-%d-%d\n",
-             sps->i_id,
-             sps->i_profile_idc, sps->i_level_idc,
-             sps->i_poc_type,
-             sps->i_num_ref_frames,
-             sps->i_mb_width, sps->i_mb_height,
-             sps->crop.i_left, sps->crop.i_right,
-             sps->crop.i_top, sps->crop.i_bottom );
-
-    return id;
-
-error:
-    /* invalidate this sps */
-    sps->i_id = -1;
-    return -1;
-}
-
-/* return -1 if invalid, else the id */
-int x264_pps_read( bs_t *s, x264_pps_t pps_array[256] )
-{
-    x264_pps_t *pps;
-    int id;
-    int i;
-
-    id = bs_read_ue( s );
-    if( bs_eof( s ) || id >= 256 )
-    {
-        fprintf( stderr, "id invalid\n" );
-        return -1;
-    }
-    pps = &pps_array[id];
-    pps->i_id = id;
-    pps->i_sps_id = bs_read_ue( s );
-    if( pps->i_sps_id >= 32 )
-    {
-        goto error;
-    }
-    pps->b_cabac = bs_read( s, 1 );
-    pps->b_pic_order = bs_read( s, 1 );
-    pps->i_num_slice_groups = bs_read_ue( s ) + 1;
-    if( pps->i_num_slice_groups > 1 )
-    {
-        fprintf( stderr, "FMO unsupported\n " );
-
-        pps->i_slice_group_map_type  =bs_read_ue( s );
-        if( pps->i_slice_group_map_type == 0 )
-        {
-            for( i = 0; i < pps->i_num_slice_groups; i++ )
-            {
-                pps->i_run_length[i] = bs_read_ue( s );
-            }
-        }
-        else if( pps->i_slice_group_map_type == 2 )
-        {
-            for( i = 0; i < pps->i_num_slice_groups; i++ )
-            {
-                pps->i_top_left[i] = bs_read_ue( s );
-                pps->i_bottom_right[i] = bs_read_ue( s );
-            }
-        }
-        else if( pps->i_slice_group_map_type == 3 ||
-                 pps->i_slice_group_map_type == 4 ||
-                 pps->i_slice_group_map_type == 5 )
-        {
-            pps->b_slice_group_change_direction = bs_read( s, 1 );
-            pps->i_slice_group_change_rate = bs_read_ue( s ) + 1;
-        }
-        else if( pps->i_slice_group_map_type == 6 )
-        {
-            pps->i_pic_size_in_map_units = bs_read_ue( s ) + 1;
-            for( i = 0; i < pps->i_pic_size_in_map_units; i++ )
-            {
-               /*  FIXME */
-                /* pps->i_slice_group_id = bs_read( s, ceil( log2( pps->i_pic_size_in_map_units +1 ) ) ); */
-            }
-        }
-    }
-    pps->i_num_ref_idx_l0_active = bs_read_ue( s ) + 1;
-    pps->i_num_ref_idx_l1_active = bs_read_ue( s ) + 1;
-    pps->b_weighted_pred = bs_read( s, 1 );
-    pps->b_weighted_bipred = bs_read( s, 2 );
-
-    pps->i_pic_init_qp = bs_read_se( s ) + 26;
-    pps->i_pic_init_qs = bs_read_se( s ) + 26;
-
-    pps->i_chroma_qp_index_offset = bs_read_se( s );
-
-    pps->b_deblocking_filter_control = bs_read( s, 1 );
-    pps->b_constrained_intra_pred = bs_read( s, 1 );
-    pps->b_redundant_pic_cnt = bs_read( s, 1 );
-
-    if( bs_eof( s ) )
-    {
-        /* no rbsp trailing */
-        fprintf( stderr, "incomplete PPS\n" );
-        goto error;
-    }
-    fprintf( stderr, "x264_sps_read: pps:0x%x sps:0x%x %s slice_groups=%d ref0:%d ref1:%d QP:%d QS:%d QC=%d DFC:%d CIP:%d RPC:%d\n",
-             pps->i_id, pps->i_sps_id,
-             pps->b_cabac ? "CABAC" : "CAVLC",
-             pps->i_num_slice_groups,
-             pps->i_num_ref_idx_l0_active,
-             pps->i_num_ref_idx_l1_active,
-             pps->i_pic_init_qp, pps->i_pic_init_qs, pps->i_chroma_qp_index_offset,
-             pps->b_deblocking_filter_control,
-             pps->b_constrained_intra_pred,
-             pps->b_redundant_pic_cnt );
-
-    return id;
-error:
-    pps->i_id = -1;
-    return -1;
-}
-
diff --git a/decoder/set.h b/decoder/set.h
deleted file mode 100644 (file)
index 6271945..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*****************************************************************************
- * set.h: h264 decoder
- *****************************************************************************
- * Copyright (C) 2003 Laurent Aimar
- * $Id: set.h,v 1.1 2004/06/03 19:27:07 fenrir Exp $
- *
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#ifndef _DECODER_SET_H
-#define _DECODER_SET_H 1
-
-/* return -1 if invalid, else the id */
-int x264_sps_read( bs_t *s, x264_sps_t sps_array[32] );
-
-/* return -1 if invalid, else the id */
-int x264_pps_read( bs_t *s, x264_pps_t pps_array[256] );
-
-#endif
diff --git a/decoder/vlc.c b/decoder/vlc.c
deleted file mode 100644 (file)
index f7535f6..0000000
+++ /dev/null
@@ -1,236 +0,0 @@
-/*****************************************************************************
- * vlc.c: VLC lookup table generation.
- *****************************************************************************
- * Copyright (C) 2003 Laurent Aimar
- * $Id: vlc.c,v 1.1 2004/06/03 19:27:07 fenrir Exp $
- *
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <inttypes.h>
-
-#include "common/common.h"
-#include "common/vlc.h"
-#include "vlc.h"
-
-
-static int  vlc_table_realloc( x264_vlc_table_t *table, int i_size )
-{
-    int i_index;
-
-    i_index = table->i_lookup;
-
-    table->i_lookup += i_size;
-    table->lookup = x264_realloc( table->lookup, sizeof( vlc_lookup_t ) * table->i_lookup );
-
-    return( i_index );
-}
-
-static int vlc_table_create_part( x264_vlc_table_t *table, const vlc_t *vlc, int i_lookup_bits, int i_nb_vlc, int i_prefix_code, int i_prefix_length )
-{
-    int i;
-    int i_nb_lookup;
-    vlc_lookup_t *lookup;
-    int i_table_index;
-
-    i_nb_lookup = 1 << i_lookup_bits;
-
-    i_table_index = vlc_table_realloc( table, i_nb_lookup );
-    lookup = &table->lookup[i_table_index];
-
-    for( i = 0; i < i_nb_lookup; i++ )
-    {
-        lookup[i].i_value  = -1;
-        lookup[i].i_size = 0;
-    }
-
-    for( i = 0; i < i_nb_vlc; i++ )
-    {
-        int i_bits;
-        if( vlc[i].i_size <= 0 )
-        {
-            continue;
-        }
-
-        i_bits = vlc[i].i_size - i_prefix_length;
-        if( i_bits > 0 && ( vlc[i].i_bits >> i_bits ) == i_prefix_code )
-        {
-            if( i_bits <= i_lookup_bits )
-            {
-                int i_lookup_index;
-                int nb;
-
-                i_lookup_index = ( vlc[i].i_bits << ( i_lookup_bits - i_bits ) )%i_nb_lookup;
-                nb = 1 << ( i_lookup_bits - i_bits );
-                for( nb = 0; nb < (1 << ( i_lookup_bits - i_bits)); nb++ )
-                {
-                    lookup[i_lookup_index].i_value = i; /* vlc[i].i_value; */
-                    lookup[i_lookup_index].i_size = i_bits;
-                    i_lookup_index++;
-                }
-            }
-            else
-            {
-                int i_bits_max;
-                int i_lookup_index;
-                /* need another table */
-                i_lookup_index = ( vlc[i].i_bits >> (i_bits - i_lookup_bits ) )%i_nb_lookup;
-
-                i_bits_max =  -lookup[i_lookup_index].i_size;
-                if( i_bits_max < i_bits - i_lookup_bits )
-                {
-                    i_bits_max = i_bits - i_lookup_bits;
-                }
-                lookup[i_lookup_index].i_size = -i_bits_max;
-            }
-        }
-    }
-
-    /* create other level table */
-    for( i = 0; i < i_nb_lookup; i++ )
-    {
-        if( lookup[i].i_size < 0 )
-        {
-            int i_bits;
-            int i_index;
-            i_bits = -lookup[i].i_size;
-            if( i_bits > i_lookup_bits )
-            {
-                lookup[i].i_size = -i_lookup_bits;
-                i_bits = i_lookup_bits;
-            }
-
-            i_index = vlc_table_create_part( table, vlc, i_bits, i_nb_vlc,
-                                             (i_prefix_code << i_lookup_bits)|i,
-                                              i_lookup_bits+i_prefix_length );
-            lookup = &table->lookup[i_table_index]; // reallocated
-            lookup[i].i_value = i_index;
-        }
-    }
-
-    return( i_table_index );
-}
-
-
-x264_vlc_table_t *x264_vlc_table_lookup_new( const vlc_t *vlc, int i_vlc, int i_lookup_bits )
-{
-    x264_vlc_table_t *table = x264_malloc( sizeof( x264_vlc_table_t ) );
-
-    table->i_lookup_bits = i_lookup_bits;
-    table->i_lookup = 0;
-    table->lookup   = NULL;
-
-    vlc_table_create_part( table, vlc, i_lookup_bits, i_vlc, 0, 0 );
-
-    return table;
-}
-
-void x264_vlc_table_lookup_delete( x264_vlc_table_t *table )
-{
-    x264_free( table->lookup );
-    x264_free( table );
-}
-
-#if 0
-void x264_vlc_table_lookup_print( x264_vlc_table_t *table )
-{
-    int idx;
-
-    fprintf( stderr, "       " );
-    for( idx = 0; idx < table->i_lookup; idx++ )
-    {
-        if( table->lookup[idx].i_value == -1 )
-        {
-            fprintf( stderr, " MKVLCLU(    -1,  0 )," );
-        }
-        else
-        {
-            fprintf( stderr, " MKVLCLU( 0x%.3x, % 2d ),", table->lookup[idx].i_value, table->lookup[idx].i_size );
-        }
-        if( (idx+1)%4 == 0 && idx < table->i_lookup - 1)
-        {
-            fprintf( stderr, "\n       " );
-        }
-    }
-    fprintf( stderr, "\n" );
-}
-
-int main(void)
-{
-    int i;
-    x264_vlc_table_t *table;
-
-
-    printf( "typedef struct\n    int i_value;\n    int i_size;\n} vlc_lookup_t;\n\n#define MKVLCLU(a,b) { .i_value=a, .i_size=b}" );
-
-    /* create vlc  entry table and then vlc_lookup_t table */
-
-    /* x264_coeff_token */
-    fprintf( stderr, "static const vlc_lookup_t x264_coeff_token_lookup[5][]=\n{\n" );
-    for( i = 0; i < 5; i++ )
-    {
-        fprintf( stderr, "    {\n" );
-        table = x264_vlc_table_lookup_new( x264_coeff_token[i], 17*4, 6 );
-        x264_vlc_table_lookup_print( table );
-        x264_vlc_table_lookup_delete( table );
-        fprintf( stderr, "    },\n" );
-    }
-    fprintf( stderr, "};\n" );
-
-#if 0
-
-    vlce = convert_vlc_to_vlce( x264_level_prefix, 16 );
-    do_vlc_table_create( vlce, 16, "x264_level_prefix_lookup", 8 );
-    free( vlce );
-
-    for( i_table = 0; i_table < 15; i_table++ )
-    {
-        char name[512];
-        vlce = convert_vlc_to_vlce( x264_total_zeros[i_table], 16 );
-        sprintf( name, "x264_total_zeros_%d", i_table );
-        do_vlc_table_create( vlce, 16, name, 6 );
-
-        free( vlce );
-    }
-
-    for( i_table = 0; i_table < 3; i_table++ )
-    {
-        char name[512];
-
-        vlce = convert_vlc_to_vlce( x264_total_zeros_dc[i_table], 4 );
-        sprintf( name, "x264_total_zeros_dc_%d", i_table );
-        do_vlc_table_create( vlce, 4, name, 3 );
-
-        free( vlce );
-    }
-
-    for( i_table = 0; i_table < 7; i_table++ )
-    {
-        char name[512];
-        vlce = convert_vlc_to_vlce( x264_run_before[i_table], 15 );
-        sprintf( name, "x264_run_before_%d", i_table );
-        do_vlc_table_create( vlce, 15, name, 6 );
-
-        free( vlce );
-    }
-#endif
-    return 0;
-}
-
-#endif
diff --git a/decoder/vlc.h b/decoder/vlc.h
deleted file mode 100644 (file)
index 9529349..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*****************************************************************************
- * vlc.h: h264 decoder
- *****************************************************************************
- * Copyright (C) 2003 Laurent Aimar
- * $Id: vlc.h,v 1.1 2004/06/03 19:27:07 fenrir Exp $
- *
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#ifndef _DECODER_VLC_H
-#define _DECODER_VLC_H 1
-
-typedef struct
-{
-    int i_value;
-    int i_size;
-} vlc_lookup_t;
-
-struct x264_vlc_table_t
-{
-    int          i_lookup_bits;
-
-    int          i_lookup;
-    vlc_lookup_t *lookup;
-};
-
-x264_vlc_table_t *x264_vlc_table_lookup_new( const vlc_t *vlc, int i_vlc, int i_lookup_bits );
-
-void x264_vlc_table_lookup_delete( x264_vlc_table_t *table );
-
-#endif
-
diff --git a/x264.c b/x264.c
index 1614aa878c0b3abcdcdf16869f6493bfbabc2352..94d6ccfc8567bac7021e703270b75f84d316f566 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * x264: h264 encoder/decoder testing program.
+ * x264: h264 encoder testing program.
  *****************************************************************************
  * Copyright (C) 2003 Laurent Aimar
  * $Id: x264.c,v 1.1 2004/06/03 19:24:12 fenrir Exp $
diff --git a/x264.h b/x264.h
index dc7e8348a8e06f3de4a54732f6ac67128ef12c7f..d9059cfe64831d06f536c9a6dd3cc2cc2a8249eb 100644 (file)
--- a/x264.h
+++ b/x264.h
@@ -38,7 +38,7 @@
 #define X264_BUILD 53
 
 /* x264_t:
- *      opaque handler for decoder and encoder */
+ *      opaque handler for encoder */
 typedef struct x264_t x264_t;
 
 /****************************************************************************
@@ -403,8 +403,6 @@ int     x264_encoder_encode ( x264_t *, x264_nal_t **, int *, x264_picture_t *,
  *      close an encoder handler */
 void    x264_encoder_close  ( x264_t * );
 
-/* XXX: decoder isn't working so no need to export it */
-
 /****************************************************************************
  * Private stuff for internal usage:
  ****************************************************************************/