From e4eadb4b44a5bd446d2f83e92a7baeddb82448ad Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 25 Aug 2003 22:54:53 +0000 Subject: [PATCH] oooooops, having 2 Eterms open and doing cvs diff in one and cvs commit in the other sucks, especially if they are in different directories (MPlayer/main/libavcodec vs. ffmpeg/libavcodec) Originally committed as revision 2165 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/avcodec.h | 7 +++--- libavcodec/motion_est.c | 54 ++--------------------------------------- libavcodec/mpegvideo.c | 24 ++++++++---------- libavcodec/mpegvideo.h | 19 +++------------ 4 files changed, 18 insertions(+), 86 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 224fbeeed9..5a158096d2 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -220,7 +220,6 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, #define CODEC_CAP_PARSE_ONLY 0x0004 #define CODEC_CAP_TRUNCATED 0x0008 - #define FF_COMMON_FRAME \ /**\ * pointer to the picture planes.\ @@ -464,7 +463,7 @@ typedef struct AVCodecContext { * do something for a generic case as well. * - decoding: set by lavc. */ - enum PixelFormat pix_fmt; //FIXME move to AVFrme + enum PixelFormat pix_fmt; /** * Frame rate emulation. If not zero lower layer (i.e. format handler) @@ -712,7 +711,7 @@ typedef struct AVCodecContext { data is returned. Only MPEG codecs support this now. */ /** - * 0-> default, 1-> mpeg quant. + * 0-> h263 quant 1-> mpeg quant. * - encoding: set by user. * - decoding: unused */ @@ -1590,7 +1589,7 @@ typedef enum { int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout); /* memory */ -void *av_malloc(unsigned int size); //FIXME unsigned could be bad, dunno, need thinking +void *av_malloc(unsigned int size); void *av_mallocz(unsigned int size); void *av_realloc(void *ptr, unsigned int size); void av_free(void *ptr); diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 3de019b4b6..17a5b1f79c 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -32,8 +32,8 @@ #include "dsputil.h" #include "mpegvideo.h" -#undef NDEBUG -#include +//#undef NDEBUG +//#include #define SQ(a) ((a)*(a)) @@ -1674,53 +1674,3 @@ void ff_fix_long_b_mvs(MpegEncContext * s, int16_t (*mv_table)[2], int f_code, i } } } -#if 0 -/** - * estimates global motion and inits sprite_ref - */ -void ff_estimate_global_motion(MpegEncContext *s, int sprite_ref[3][2]){ - int y; - int num= 16<f_code; - int score[2][num]; - int best_i[2]={0,0}; - int best_score[2]={0,0}; - - memset(score, 0, 2*num*sizeof(int)); - - for(y=0; ymb_height; y++){ - int x; - int xy= (y+1)* (s->mb_width+2)+1; - int i= y*s->mb_width; - for(x=0; xmb_width; x++){ - int mv[2]; - - if(!(s->mb_type[i]&MB_TYPE_INTER)) - continue; - - mv[0]= s->p_mv_table[xy][0]; - mv[1]= s->p_mv_table[xy][1]; - - if(mv[0]==0 && mv[1]==0) continue; - - score[0][mv[0] + num/2]++; - score[1][mv[1] + num/2]++; - } - } - - for(n=0; n<2; n++){ - for(i=1; i best_score[n]){ - best_score[n]= s; - best_i[n]= i; - } - } - } - - sprite_ref[0][0]= best_i[0] - num/2; - sprite_ref[0][1]= best_i[1] - num/2; - - // decide block type -} -#endif diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 56f1662978..f675d1cd53 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -34,8 +34,8 @@ #include "fastmemcpy.h" #endif -#undef NDEBUG -#include +//#undef NDEBUG +//#include #ifdef CONFIG_ENCODERS static void encode_picture(MpegEncContext *s, int picture_number); @@ -191,7 +191,7 @@ int DCT_common_init(MpegEncContext *s) #endif #ifdef HAVE_MMX - MPV_common_init_mmx(s); //FIXME dont pass mpegenccontext to these, rather use dspcontext + MPV_common_init_mmx(s); #endif #ifdef ARCH_ALPHA MPV_common_init_axp(s); @@ -279,7 +279,7 @@ static int alloc_picture(MpegEncContext *s, Picture *pic, int shared){ } CHECKED_ALLOCZ(pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2) //the +2 is for the slice end check - CHECKED_ALLOCZ(pic->qscale_table , mb_array_size * sizeof(uint8_t)+3) //+3 for mpeg2 SIMD >>1 + CHECKED_ALLOCZ(pic->qscale_table , mb_array_size * sizeof(uint8_t)) CHECKED_ALLOCZ(pic->mb_type_base , big_mb_num * sizeof(int)) pic->mb_type= pic->mb_type_base + s->mb_stride+1; if(s->out_format == FMT_H264){ @@ -424,7 +424,7 @@ int MPV_common_init(MpegEncContext *s) CHECKED_ALLOCZ(s->error_status_table, mb_array_size*sizeof(uint8_t)) - if (s->out_format == FMT_H263 || s->encoding || 1) { + if (s->out_format == FMT_H263 || s->encoding) { int size; /* MV prediction */ @@ -581,7 +581,7 @@ int MPV_encode_init(AVCodecContext *avctx) s->data_partitioning= avctx->flags & CODEC_FLAG_PART; s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0; s->mpeg_quant= avctx->mpeg_quant; - + if (s->gop_size <= 1) { s->intra_only = 1; s->gop_size = 12; @@ -622,12 +622,12 @@ int MPV_encode_init(AVCodecContext *avctx) fprintf(stderr, "b frames not supporetd by codec\n"); return -1; } -/* + if(s->mpeg_quant && s->codec_id != CODEC_ID_MPEG4){ //FIXME mpeg2 uses that too fprintf(stderr, "mpeg2 style quantization not supporetd by codec\n"); return -1; } - */ + if(s->codec_id==CODEC_ID_MJPEG){ s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x s->inter_quant_bias= 0; @@ -1009,7 +1009,6 @@ alloc: if( alloc_picture(s, (Picture*)pic, 0) < 0) return -1; - assert(pic->data[0]); s->current_picture_ptr= &s->picture[i]; } @@ -2352,8 +2351,7 @@ static inline void MPV_motion(MpegEncContext *s, } } break; - default: - printf("X"); + } } @@ -3005,9 +3003,7 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y) for(i=0;i<6;i++) { if(!skip_dct[i]){ int overflow; -START_TIMER; s->block_last_index[i] = s->dct_quantize(s, s->block[i], i, s->qscale, &overflow); -STOP_TIMER("dct_quant"); // FIXME we could decide to change to quantizer instead of clipping // JS: I don't think that would be a good idea it could lower quality instead // of improve it. Just INTRADC clipping deserves changes in quantizer @@ -4018,7 +4014,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s, start_i = 1; last_non_zero = 0; qmat = s->q_intra_matrix[qscale]; - if(s->mpeg_quant) + if(s->mpeg_quant || s->out_format == FMT_MPEG1) bias= 1<<(QMAT_SHIFT-1); length = s->intra_ac_vlc_length; last_length= s->intra_ac_vlc_last_length; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 279c7f9467..db56c3ba52 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -48,13 +48,8 @@ enum OutputFormat { #define MAX_PICTURE_COUNT 15 -#if 1 -#define ME_MAP_SIZE 4096 -#define ME_MAP_SHIFT 6 -#else #define ME_MAP_SIZE 64 #define ME_MAP_SHIFT 3 -#endif #define ME_MAP_MV_BITS 11 /* run length table */ @@ -390,10 +385,8 @@ typedef struct MpegEncContext { int me_method; ///< ME algorithm int scene_change_score; int mv_dir; -#define MV_DIR_L1 1 -#define MV_DIR_L0 2 -#define MV_DIR_BACKWARD MV_DIR_L1 -#define MV_DIR_FORWARD MV_DIR_L0 +#define MV_DIR_BACKWARD 1 +#define MV_DIR_FORWARD 2 #define MV_DIRECT 4 ///< bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4) int mv_type; #define MV_TYPE_16X16 0 ///< 1 vector for the whole mb @@ -575,11 +568,6 @@ typedef struct MpegEncContext { uint8_t *tex_pb_buffer; uint8_t *pb2_buffer; int mpeg_quant; -#define FF_QUANT_DEFAULT 0 -#define FF_QUANT_MPEG2 1 -#define FF_QUANT_MPEG1 2 -#define FF_QUANT_H263 3 - int16_t (*field_mv_table)[2][2]; ///< used for interlaced b frame decoding int8_t (*field_select_table)[2]; ///< wtf, no really another table for interlaced b frames int t_frame; ///< time distance of first I -> B, used for interlaced b frames @@ -663,7 +651,7 @@ typedef struct MpegEncContext { /* RTP specific */ /* These are explained on avcodec.h */ - int rtp_mode; //FIXME simplify this mess (remove callback, merge mode + payload) + int rtp_mode; int rtp_payload_size; void (*rtp_callback)(void *data, int size, int packet_number); uint8_t *ptr_lastgob; @@ -881,7 +869,6 @@ int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size); int ff_msmpeg4_decode_init(MpegEncContext *s); void ff_msmpeg4_encode_init(MpegEncContext *s); int ff_wmv2_decode_picture_header(MpegEncContext * s); -int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s); void ff_wmv2_add_mb(MpegEncContext *s, DCTELEM block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr); void ff_mspel_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,