Commit 3d2e8cce authored by Michael Niedermayer's avatar Michael Niedermayer

ASV1 codec

with postprocessing support :)

Originally committed as revision 1891 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 22493ab9
...@@ -17,7 +17,7 @@ OBJS= common.o utils.o mem.o allcodecs.o \ ...@@ -17,7 +17,7 @@ OBJS= common.o utils.o mem.o allcodecs.o \
mpeg12.o mpegaudiodec.o pcm.o simple_idct.o \ mpeg12.o mpegaudiodec.o pcm.o simple_idct.o \
ratecontrol.o adpcm.o eval.o dv.o error_resilience.o \ ratecontrol.o adpcm.o eval.o dv.o error_resilience.o \
fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \ fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \
vp3.o vp3.o asv1.o
ifeq ($(AMR_NB),yes) ifeq ($(AMR_NB),yes)
OBJS+= amr.o OBJS+= amr.o
......
...@@ -64,6 +64,7 @@ void avcodec_register_all(void) ...@@ -64,6 +64,7 @@ void avcodec_register_all(void)
#endif #endif
register_avcodec(&mjpeg_encoder); register_avcodec(&mjpeg_encoder);
register_avcodec(&huffyuv_encoder); register_avcodec(&huffyuv_encoder);
register_avcodec(&asv1_encoder);
#endif /* CONFIG_ENCODERS */ #endif /* CONFIG_ENCODERS */
register_avcodec(&rawvideo_encoder); register_avcodec(&rawvideo_encoder);
register_avcodec(&rawvideo_decoder); register_avcodec(&rawvideo_decoder);
...@@ -103,6 +104,7 @@ void avcodec_register_all(void) ...@@ -103,6 +104,7 @@ void avcodec_register_all(void)
register_avcodec(&cyuv_decoder); register_avcodec(&cyuv_decoder);
register_avcodec(&h264_decoder); register_avcodec(&h264_decoder);
register_avcodec(&vp3_decoder); register_avcodec(&vp3_decoder);
register_avcodec(&asv1_decoder);
#ifdef CONFIG_AC3 #ifdef CONFIG_AC3
register_avcodec(&ac3_decoder); register_avcodec(&ac3_decoder);
#endif #endif
......
This diff is collapsed.
...@@ -15,8 +15,8 @@ extern "C" { ...@@ -15,8 +15,8 @@ extern "C" {
#define LIBAVCODEC_VERSION_INT 0x000406 #define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6" #define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_BUILD 4667 #define LIBAVCODEC_BUILD 4668
#define LIBAVCODEC_BUILD_STR "4667" #define LIBAVCODEC_BUILD_STR "4668"
#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
...@@ -55,6 +55,7 @@ enum CodecID { ...@@ -55,6 +55,7 @@ enum CodecID {
CODEC_ID_VP3, CODEC_ID_VP3,
CODEC_ID_AAC, CODEC_ID_AAC,
CODEC_ID_MPEG4AAC, CODEC_ID_MPEG4AAC,
CODEC_ID_ASV1,
/* various pcm "codecs" */ /* various pcm "codecs" */
CODEC_ID_PCM_S16LE, CODEC_ID_PCM_S16LE,
...@@ -1108,6 +1109,15 @@ typedef struct AVCodecContext { ...@@ -1108,6 +1109,15 @@ typedef struct AVCodecContext {
* Dont touch, used by lavc default_get_buffer() * Dont touch, used by lavc default_get_buffer()
*/ */
void *internal_buffer; void *internal_buffer;
#define FF_QUALITY_SCALE 256
/**
* global quality for codecs which cannot change it per frame.
* this should be proportional to MPEG1/2/4 qscale.
* - encoding: set by user.
* - decoding: unused
*/
int global_quality;
} AVCodecContext; } AVCodecContext;
...@@ -1199,6 +1209,7 @@ extern AVCodec wmv1_encoder; ...@@ -1199,6 +1209,7 @@ extern AVCodec wmv1_encoder;
extern AVCodec wmv2_encoder; extern AVCodec wmv2_encoder;
extern AVCodec huffyuv_encoder; extern AVCodec huffyuv_encoder;
extern AVCodec h264_encoder; extern AVCodec h264_encoder;
extern AVCodec asv1_encoder;
extern AVCodec h263_decoder; extern AVCodec h263_decoder;
extern AVCodec mpeg4_decoder; extern AVCodec mpeg4_decoder;
...@@ -1231,6 +1242,7 @@ extern AVCodec vp3_decoder; ...@@ -1231,6 +1242,7 @@ extern AVCodec vp3_decoder;
extern AVCodec amr_nb_decoder; extern AVCodec amr_nb_decoder;
extern AVCodec aac_decoder; extern AVCodec aac_decoder;
extern AVCodec mpeg4aac_decoder; extern AVCodec mpeg4aac_decoder;
extern AVCodec asv1_decoder;
/* pcm codecs */ /* pcm codecs */
#define PCM_CODEC(id, name) \ #define PCM_CODEC(id, name) \
......
...@@ -908,9 +908,18 @@ static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits ...@@ -908,9 +908,18 @@ static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits
printf("%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line); printf("%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
return r; return r;
} }
static inline int get_xbits_trace(GetBitContext *s, int n, char *file, char *func, int line){
int show= show_bits(s, n);
int r= get_xbits(s, n);
print_bin(show, n);
printf("%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line);
return r;
}
#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) #define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__) #define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) #define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) #define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
......
...@@ -187,6 +187,23 @@ static int pix_norm1_c(uint8_t * pix, int line_size) ...@@ -187,6 +187,23 @@ static int pix_norm1_c(uint8_t * pix, int line_size)
return s; return s;
} }
static void bswap_buf(uint32_t *dst, uint32_t *src, int w){
int i;
for(i=0; i+8<=w; i+=8){
dst[i+0]= bswap_32(src[i+0]);
dst[i+1]= bswap_32(src[i+1]);
dst[i+2]= bswap_32(src[i+2]);
dst[i+3]= bswap_32(src[i+3]);
dst[i+4]= bswap_32(src[i+4]);
dst[i+5]= bswap_32(src[i+5]);
dst[i+6]= bswap_32(src[i+6]);
dst[i+7]= bswap_32(src[i+7]);
}
for(;i<w; i++){
dst[i+0]= bswap_32(src[i+0]);
}
}
static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size) static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size)
{ {
...@@ -2879,6 +2896,7 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx) ...@@ -2879,6 +2896,7 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->add_bytes= add_bytes_c; c->add_bytes= add_bytes_c;
c->diff_bytes= diff_bytes_c; c->diff_bytes= diff_bytes_c;
c->bswap_buf= bswap_buf;
#ifdef HAVE_MMX #ifdef HAVE_MMX
dsputil_init_mmx(c, avctx); dsputil_init_mmx(c, avctx);
......
...@@ -234,6 +234,7 @@ typedef struct DSPContext { ...@@ -234,6 +234,7 @@ typedef struct DSPContext {
/* huffyuv specific */ /* huffyuv specific */
void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w); void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w); void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w);
void (*bswap_buf)(uint32_t *dst, uint32_t *src, int w);
/* (I)DCT */ /* (I)DCT */
void (*fdct)(DCTELEM *block/* align 16*/); void (*fdct)(DCTELEM *block/* align 16*/);
......
...@@ -4731,15 +4731,15 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){ ...@@ -4731,15 +4731,15 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
} }
if(s->alternate_scan){ if(s->alternate_scan){
ff_init_scantable(s, &s->inter_scantable , ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan);
ff_init_scantable(s, &s->intra_scantable , ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan);
ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
} else{ } else{
ff_init_scantable(s, &s->inter_scantable , ff_zigzag_direct); ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct);
ff_init_scantable(s, &s->intra_scantable , ff_zigzag_direct); ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct);
ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_horizontal_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
} }
if(s->pict_type == S_TYPE && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){ if(s->pict_type == S_TYPE && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
......
...@@ -117,24 +117,6 @@ static const unsigned char classic_add_chroma[256] = { ...@@ -117,24 +117,6 @@ static const unsigned char classic_add_chroma[256] = {
6, 12, 8, 10, 7, 9, 6, 4, 6, 2, 2, 3, 3, 3, 3, 2, 6, 12, 8, 10, 7, 9, 6, 4, 6, 2, 2, 3, 3, 3, 3, 2,
}; };
static inline void bswap_buf(uint32_t *dst, uint32_t *src, int w){
int i;
for(i=0; i+8<=w; i+=8){
dst[i+0]= bswap_32(src[i+0]);
dst[i+1]= bswap_32(src[i+1]);
dst[i+2]= bswap_32(src[i+2]);
dst[i+3]= bswap_32(src[i+3]);
dst[i+4]= bswap_32(src[i+4]);
dst[i+5]= bswap_32(src[i+5]);
dst[i+6]= bswap_32(src[i+6]);
dst[i+7]= bswap_32(src[i+7]);
}
for(;i<w; i++){
dst[i+0]= bswap_32(src[i+0]);
}
}
static inline int add_left_prediction(uint8_t *dst, uint8_t *src, int w, int acc){ static inline int add_left_prediction(uint8_t *dst, uint8_t *src, int w, int acc){
int i; int i;
...@@ -749,7 +731,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8 ...@@ -749,7 +731,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
if (buf_size == 0) if (buf_size == 0)
return 0; return 0;
bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4); s->dsp.bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4);
init_get_bits(&s->gb, s->bitstream_buffer, buf_size*8); init_get_bits(&s->gb, s->bitstream_buffer, buf_size*8);
...@@ -1126,7 +1108,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, ...@@ -1126,7 +1108,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
} }
}else{ }else{
flush_put_bits(&s->pb); flush_put_bits(&s->pb);
bswap_buf((uint32_t*)buf, (uint32_t*)buf, size); s->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size);
} }
s->picture_number++; s->picture_number++;
......
...@@ -1721,15 +1721,15 @@ static void mpeg_decode_picture_coding_extension(MpegEncContext *s) ...@@ -1721,15 +1721,15 @@ static void mpeg_decode_picture_coding_extension(MpegEncContext *s)
} }
if(s->alternate_scan){ if(s->alternate_scan){
ff_init_scantable(s, &s->inter_scantable , ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan);
ff_init_scantable(s, &s->intra_scantable , ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan);
ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
}else{ }else{
ff_init_scantable(s, &s->inter_scantable , ff_zigzag_direct); ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct);
ff_init_scantable(s, &s->intra_scantable , ff_zigzag_direct); ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct);
ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_horizontal_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
} }
/* composite display not parsed */ /* composite display not parsed */
......
...@@ -136,7 +136,7 @@ static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16 ...@@ -136,7 +136,7 @@ static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16
} }
#endif //CONFIG_ENCODERS #endif //CONFIG_ENCODERS
void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scantable){ void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){
int i; int i;
int end; int end;
...@@ -145,7 +145,7 @@ void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scan ...@@ -145,7 +145,7 @@ void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scan
for(i=0; i<64; i++){ for(i=0; i<64; i++){
int j; int j;
j = src_scantable[i]; j = src_scantable[i];
st->permutated[i] = s->dsp.idct_permutation[j]; st->permutated[i] = permutation[j];
#ifdef ARCH_POWERPC #ifdef ARCH_POWERPC
st->inverse[j] = i; st->inverse[j] = i;
#endif #endif
...@@ -202,10 +202,10 @@ int DCT_common_init(MpegEncContext *s) ...@@ -202,10 +202,10 @@ int DCT_common_init(MpegEncContext *s)
/* load & permutate scantables /* load & permutate scantables
note: only wmv uses differnt ones note: only wmv uses differnt ones
*/ */
ff_init_scantable(s, &s->inter_scantable , ff_zigzag_direct); ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct);
ff_init_scantable(s, &s->intra_scantable , ff_zigzag_direct); ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct);
ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_horizontal_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
s->picture_structure= PICT_FRAME; s->picture_structure= PICT_FRAME;
......
...@@ -706,7 +706,7 @@ void MPV_common_init_ppc(MpegEncContext *s); ...@@ -706,7 +706,7 @@ void MPV_common_init_ppc(MpegEncContext *s);
extern void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w); extern void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w);
void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length); void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length);
void ff_clean_intra_table_entries(MpegEncContext *s); void ff_clean_intra_table_entries(MpegEncContext *s);
void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scantable); void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
void ff_draw_horiz_band(MpegEncContext *s, int y, int h); void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
void ff_emulated_edge_mc(MpegEncContext *s, uint8_t *src, int linesize, int block_w, int block_h, void ff_emulated_edge_mc(MpegEncContext *s, uint8_t *src, int linesize, int block_w, int block_h,
int src_x, int src_y, int w, int h); int src_x, int src_y, int w, int h);
......
...@@ -180,10 +180,10 @@ static void common_init(MpegEncContext * s) ...@@ -180,10 +180,10 @@ static void common_init(MpegEncContext * s)
if(s->msmpeg4_version>=4){ if(s->msmpeg4_version>=4){
ff_init_scantable(s, &s->intra_scantable , wmv1_scantable[1]); ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , wmv1_scantable[1]);
ff_init_scantable(s, &s->intra_h_scantable, wmv1_scantable[2]); ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, wmv1_scantable[2]);
ff_init_scantable(s, &s->intra_v_scantable, wmv1_scantable[3]); ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, wmv1_scantable[3]);
ff_init_scantable(s, &s->inter_scantable , wmv1_scantable[0]); ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , wmv1_scantable[0]);
} }
//Note the default tables are set in common_init in mpegvideo.c //Note the default tables are set in common_init in mpegvideo.c
......
...@@ -55,8 +55,8 @@ typedef struct Wmv2Context{ ...@@ -55,8 +55,8 @@ typedef struct Wmv2Context{
static void wmv2_common_init(Wmv2Context * w){ static void wmv2_common_init(Wmv2Context * w){
MpegEncContext * const s= &w->s; MpegEncContext * const s= &w->s;
ff_init_scantable(s, &w->abt_scantable[0], wmv2_scantableA); ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[0], wmv2_scantableA);
ff_init_scantable(s, &w->abt_scantable[1], wmv2_scantableB); ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[1], wmv2_scantableB);
} }
static int encode_ext_header(Wmv2Context *w){ static int encode_ext_header(Wmv2Context *w){
......
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