Commit 9abc7e0f authored by Michael Niedermayer's avatar Michael Niedermayer

intrax8 decoder patch by "someone"

Originally committed as revision 10971 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent a9d5a448
......@@ -188,7 +188,7 @@ OBJS-$(CONFIG_TTA_DECODER) += tta.o
OBJS-$(CONFIG_TXD_DECODER) += txd.o s3tc.o
OBJS-$(CONFIG_ULTI_DECODER) += ulti.o
OBJS-$(CONFIG_VB_DECODER) += vb.o
OBJS-$(CONFIG_VC1_DECODER) += vc1.o vc1data.o vc1dsp.o msmpeg4data.o
OBJS-$(CONFIG_VC1_DECODER) += vc1.o vc1data.o vc1dsp.o msmpeg4data.o intrax8.o intrax8dsp.o
OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o
OBJS-$(CONFIG_VCR1_ENCODER) += vcr1.o
OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o
......@@ -209,8 +209,8 @@ OBJS-$(CONFIG_WMAV1_ENCODER) += wmaenc.o wma.o mdct.o fft.o
OBJS-$(CONFIG_WMAV2_ENCODER) += wmaenc.o wma.o mdct.o fft.o
OBJS-$(CONFIG_WMV1_DECODER) += h263dec.o h263.o
OBJS-$(CONFIG_WMV1_ENCODER) += mpegvideo_enc.o motion_est.o ratecontrol.o h263.o
OBJS-$(CONFIG_WMV2_DECODER) += wmv2.o msmpeg4.o msmpeg4data.o h263dec.o h263.o
OBJS-$(CONFIG_WMV2_ENCODER) += wmv2.o msmpeg4.o msmpeg4data.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o
OBJS-$(CONFIG_WMV2_DECODER) += wmv2.o msmpeg4.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o
OBJS-$(CONFIG_WMV2_ENCODER) += wmv2.o msmpeg4.o msmpeg4data.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o intrax8.o intrax8dsp.o
OBJS-$(CONFIG_WMV3_DECODER) += vc1.o vc1data.o vc1dsp.o
OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o
OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o
......
......@@ -1295,6 +1295,7 @@ typedef struct AVCodecContext {
#define FF_IDCT_SIMPLEARMV5TE 16
#define FF_IDCT_SIMPLEARMV6 17
#define FF_IDCT_SIMPLEVIS 18
#define FF_IDCT_WMV2 19
/**
* slice count
......
......@@ -2561,6 +2561,10 @@ void ff_put_vc1_mspel_mc00_c(uint8_t *dst, uint8_t *src, int stride, int rnd) {
}
#endif /* CONFIG_VC1_DECODER||CONFIG_WMV3_DECODER */
#if defined(CONFIG_WMV2_DECODER) || defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER)
void ff_intrax8dsp_init(DSPContext* c, AVCodecContext *avctx);
#endif
#if defined(CONFIG_H264_ENCODER)
/* H264 specific */
void ff_h264dspenc_init(DSPContext* c, AVCodecContext *avctx);
......@@ -3758,8 +3762,90 @@ void ff_float_to_int16_c(int16_t *dst, const float *src, int len){
}
}
#define W0 2048
#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */
#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */
#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */
#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */
#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */
#define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */
static void wmv2_idct_row(short * b)
{
int s1,s2;
int a0,a1,a2,a3,a4,a5,a6,a7;
/*step 1*/
a1 = W1*b[1]+W7*b[7];
a7 = W7*b[1]-W1*b[7];
a5 = W5*b[5]+W3*b[3];
a3 = W3*b[5]-W5*b[3];
a2 = W2*b[2]+W6*b[6];
a6 = W6*b[2]-W2*b[6];
a0 = W0*b[0]+W0*b[4];
a4 = W0*b[0]-W0*b[4];
/*step 2*/
s1 = (181*(a1-a5+a7-a3)+128)>>8;//1,3,5,7,
s2 = (181*(a1-a5-a7+a3)+128)>>8;
/*step 3*/
b[0] = (a0+a2+a1+a5 + (1<<7))>>8;
b[1] = (a4+a6 +s1 + (1<<7))>>8;
b[2] = (a4-a6 +s2 + (1<<7))>>8;
b[3] = (a0-a2+a7+a3 + (1<<7))>>8;
b[4] = (a0-a2-a7-a3 + (1<<7))>>8;
b[5] = (a4-a6 -s2 + (1<<7))>>8;
b[6] = (a4+a6 -s1 + (1<<7))>>8;
b[7] = (a0+a2-a1-a5 + (1<<7))>>8;
}
static void wmv2_idct_col(short * b)
{
int s1,s2;
int a0,a1,a2,a3,a4,a5,a6,a7;
/*step 1, with extended precision*/
a1 = (W1*b[8*1]+W7*b[8*7] + 4)>>3;
a7 = (W7*b[8*1]-W1*b[8*7] + 4)>>3;
a5 = (W5*b[8*5]+W3*b[8*3] + 4)>>3;
a3 = (W3*b[8*5]-W5*b[8*3] + 4)>>3;
a2 = (W2*b[8*2]+W6*b[8*6] + 4)>>3;
a6 = (W6*b[8*2]-W2*b[8*6] + 4)>>3;
a0 = (W0*b[8*0]+W0*b[8*4] )>>3;
a4 = (W0*b[8*0]-W0*b[8*4] )>>3;
/*step 2*/
s1 = (181*(a1-a5+a7-a3)+128)>>8;
s2 = (181*(a1-a5-a7+a3)+128)>>8;
/*step 3*/
b[8*0] = (a0+a2+a1+a5 + (1<<13))>>14;
b[8*1] = (a4+a6 +s1 + (1<<13))>>14;
b[8*2] = (a4-a6 +s2 + (1<<13))>>14;
b[8*3] = (a0-a2+a7+a3 + (1<<13))>>14;
b[8*4] = (a0-a2-a7-a3 + (1<<13))>>14;
b[8*5] = (a4-a6 -s2 + (1<<13))>>14;
b[8*6] = (a4+a6 -s1 + (1<<13))>>14;
b[8*7] = (a0+a2-a1-a5 + (1<<13))>>14;
}
void ff_wmv2_idct_c(short * block){
int i;
for(i=0;i<64;i+=8){
wmv2_idct_row(block+i);
}
for(i=0;i<8;i++){
wmv2_idct_col(block+i);
}
}
/* XXX: those functions should be suppressed ASAP when all IDCTs are
converted */
static void ff_wmv2_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_wmv2_idct_c(block);
put_pixels_clamped_c(block, dest, line_size);
}
static void ff_wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_wmv2_idct_c(block);
add_pixels_clamped_c(block, dest, line_size);
}
static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
{
j_rev_dct (block);
......@@ -3899,6 +3985,11 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->idct_add= ff_vp3_idct_add_c;
c->idct = ff_vp3_idct_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else if(avctx->idct_algo==FF_IDCT_WMV2){
c->idct_put= ff_wmv2_idct_put_c;
c->idct_add= ff_wmv2_idct_add_c;
c->idct = ff_wmv2_idct_c;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else{ //accurate/default
c->idct_put= simple_idct_put;
c->idct_add= simple_idct_add;
......@@ -4056,6 +4147,9 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
#if defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER)
ff_vc1dsp_init(c,avctx);
#endif
#if defined(CONFIG_WMV2_DECODER) || defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER)
ff_intrax8dsp_init(c,avctx);
#endif
#if defined(CONFIG_H264_ENCODER)
ff_h264dspenc_init(c,avctx);
#endif
......
......@@ -48,6 +48,7 @@ void j_rev_dct (DCTELEM *data);
void j_rev_dct4 (DCTELEM *data);
void j_rev_dct2 (DCTELEM *data);
void j_rev_dct1 (DCTELEM *data);
void ff_wmv2_idct_c(DCTELEM *data);
void ff_fdct_mmx(DCTELEM *block);
void ff_fdct_mmx2(DCTELEM *block);
......@@ -326,6 +327,9 @@ typedef struct DSPContext {
void (*h261_loop_filter)(uint8_t *src, int stride);
void (*x8_v_loop_filter)(uint8_t *src, int stride, int qscale);
void (*x8_h_loop_filter)(uint8_t *src, int stride, int qscale);
/* assume len is a multiple of 4, and arrays are 16-byte aligned */
void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize);
/* no alignment needed */
......@@ -412,6 +416,12 @@ typedef struct DSPContext {
* last argument is actually round value instead of height
*/
op_pixels_func put_vc1_mspel_pixels_tab[16];
/* intrax8 functions */
void (*x8_spacial_compensation[12])(uint8_t *src , uint8_t *dst, int linesize);
void (*x8_setup_spacial_compensation)(uint8_t *src, uint8_t *dst, int linesize,
int * range, int * sum, int edges);
} DSPContext;
void dsputil_static_init(void);
......
......@@ -623,9 +623,10 @@ retry:
//the second part of the wmv2 header contains the MB skip bits which are stored in current_picture->mb_type
//which is not available before MPV_frame_start()
if (s->msmpeg4_version==5){
if(!ENABLE_WMV2_DECODER || ff_wmv2_decode_secondary_picture_header(s) < 0)
return -1;
if (ENABLE_WMV2_DECODER && s->msmpeg4_version==5){
ret = ff_wmv2_decode_secondary_picture_header(s);
if(ret<0) return ret;
if(ret==1) goto intrax8_decoded;
}
/* decode each macroblock */
......@@ -682,6 +683,7 @@ retry:
}
}
intrax8_decoded:
ff_er_frame_end(s);
MPV_frame_end(s);
......
This diff is collapsed.
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
typedef struct{
VLC * j_ac_vlc[4];//they point to the static j_mb_vlc
VLC * j_orient_vlc;
VLC * j_dc_vlc[3];
int use_quant_matrix;
//set by ff_intrax8_common_init
uint8_t * prediction_table;//2*(mb_w*2)
ScanTable scantable[3];
//set by the caller codec
MpegEncContext * s;
int quant;
int dquant;
int qsum;
//calculated per frame
int quant_dc_chroma;
int divide_quant_dc_luma;
int divide_quant_dc_chroma;
//changed per block
int edges;
int flat_dc;
int predicted_dc;
int raw_orient;
int chroma_orient;
int orient;
int est_run;
//#ifdef DEBUG
int mode_index[10];//debug only
//#endif
} IntraX8Context;
void ff_intrax8_common_init(IntraX8Context * w, MpegEncContext * const s);
int ff_intrax8_decode_picture(IntraX8Context * w, int quant, int halfpq);
This diff is collapsed.
This diff is collapsed.
......@@ -1100,8 +1100,8 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
if (v->multires && v->s.pict_type != B_TYPE) v->respic = get_bits(gb, 2);
if(v->res_x8 && (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)){
if(get_bits1(gb))return -1;
}
v->x8_type = get_bits1(gb);
}else v->x8_type = 0;
//av_log(v->s.avctx, AV_LOG_INFO, "%c Frame: QP=[%i]%i (+%i/2) %i\n",
// (v->s.pict_type == P_TYPE) ? 'P' : ((v->s.pict_type == I_TYPE) ? 'I' : 'B'), pqindex, v->pq, v->halfpq, v->rangeredfrm);
......@@ -1234,6 +1234,8 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
break;
}
if(!v->x8_type)
{
/* AC Syntax */
v->c_ac_table_index = decode012(gb);
if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)
......@@ -1242,6 +1244,7 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
}
/* DC Syntax */
v->s.dc_table_index = get_bits1(gb);
}
if(v->s.pict_type == BI_TYPE) {
v->s.pict_type = B_TYPE;
......@@ -3755,6 +3758,9 @@ static void vc1_decode_blocks(VC1Context *v)
{
v->s.esc3_level_length = 0;
if(v->x8_type){
ff_intrax8_decode_picture(&v->x8, 2*v->pq+v->halfpq, v->pq*(!v->pquantizer) );
}else
switch(v->s.pict_type) {
case I_TYPE:
......@@ -3835,6 +3841,10 @@ static int vc1_decode_init(AVCodecContext *avctx)
avctx->flags |= CODEC_FLAG_EMU_EDGE;
v->s.flags |= CODEC_FLAG_EMU_EDGE;
if(avctx->idct_algo==FF_IDCT_AUTO){
avctx->idct_algo=FF_IDCT_WMV2;
}
if(ff_h263_decode_init(avctx) < 0)
return -1;
if (vc1_init_common(v) < 0) return -1;
......@@ -3935,6 +3945,7 @@ static int vc1_decode_init(AVCodecContext *avctx)
// return -1;
}
ff_intrax8_common_init(&v->x8,s);
return 0;
}
......
......@@ -25,6 +25,7 @@
#include "avcodec.h"
#include "mpegvideo.h"
#include "intrax8.h"
/** Markers used in VC-1 AP frame data */
//@{
......@@ -156,6 +157,7 @@ enum COTypes {
*/
typedef struct VC1Context{
MpegEncContext s;
IntraX8Context x8;
int bits;
......@@ -302,6 +304,7 @@ typedef struct VC1Context{
int p_frame_skipped;
int bi_type;
int x8_type;
} VC1Context;
#endif /* FFMPEG_VC1_H */
......@@ -29,6 +29,7 @@
#include "msmpeg4.h"
#include "msmpeg4data.h"
#include "simple_idct.h"
#include "intrax8.h"
#define SKIP_TYPE_NONE 0
#define SKIP_TYPE_MPEG 1
......@@ -38,6 +39,7 @@
typedef struct Wmv2Context{
MpegEncContext s;
IntraX8Context x8;
int j_type_bit;
int j_type;
int abt_flag;
......@@ -472,12 +474,9 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s)
s->picture_number++; //FIXME ?
// if(w->j_type)
// return wmv2_decode_j_picture(w); //FIXME
if(w->j_type){
av_log(s->avctx, AV_LOG_ERROR, "J-type picture is not supported\n");
return -1;
ff_intrax8_decode_picture(&w->x8, 2*s->qscale, (s->qscale-1)|1 );
return 1;
}
return 0;
......@@ -830,11 +829,17 @@ int ff_wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
static int wmv2_decode_init(AVCodecContext *avctx){
Wmv2Context * const w= avctx->priv_data;
if(avctx->idct_algo==FF_IDCT_AUTO){
avctx->idct_algo=FF_IDCT_WMV2;
}
if(ff_h263_decode_init(avctx) < 0)
return -1;
wmv2_common_init(w);
ff_intrax8_common_init(&w->x8,&w->s);
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment