Commit 029911d1 authored by Michael Niedermayer's avatar Michael Niedermayer

mpeg2 encoding

Originally committed as revision 2164 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 9b6a5b87
......@@ -52,6 +52,7 @@ void avcodec_register_all(void)
register_avcodec(&mpeg1video_encoder);
// register_avcodec(&h264_encoder);
#ifdef CONFIG_RISKY
register_avcodec(&mpeg2video_encoder);
register_avcodec(&h263_encoder);
register_avcodec(&h263p_encoder);
register_avcodec(&flv_encoder);
......
......@@ -15,14 +15,15 @@ extern "C" {
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_BUILD 4675
#define LIBAVCODEC_BUILD_STR "4675"
#define LIBAVCODEC_BUILD 4676
#define LIBAVCODEC_BUILD_STR "4676"
#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
enum CodecID {
CODEC_ID_NONE,
CODEC_ID_MPEG1VIDEO,
CODEC_ID_MPEG2VIDEO,
CODEC_ID_MPEG2VIDEO_XVMC,
CODEC_ID_H263,
CODEC_ID_RV10,
......@@ -219,6 +220,7 @@ 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.\
......@@ -462,7 +464,7 @@ typedef struct AVCodecContext {
* do something for a generic case as well.
* - decoding: set by lavc.
*/
enum PixelFormat pix_fmt;
enum PixelFormat pix_fmt; //FIXME move to AVFrme
/**
* Frame rate emulation. If not zero lower layer (i.e. format handler)
......@@ -710,7 +712,7 @@ typedef struct AVCodecContext {
data is returned. Only MPEG codecs support this now. */
/**
* 0-> h263 quant 1-> mpeg quant.
* 0-> default, 1-> mpeg quant.
* - encoding: set by user.
* - decoding: unused
*/
......@@ -1281,6 +1283,7 @@ extern AVCodec mp2_encoder;
extern AVCodec mp3lame_encoder;
extern AVCodec oggvorbis_encoder;
extern AVCodec mpeg1video_encoder;
extern AVCodec mpeg2video_encoder;
extern AVCodec h263_encoder;
extern AVCodec h263p_encoder;
extern AVCodec flv_encoder;
......@@ -1587,7 +1590,7 @@ typedef enum {
int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
/* memory */
void *av_malloc(unsigned int size);
void *av_malloc(unsigned int size); //FIXME unsigned could be bad, dunno, need thinking
void *av_mallocz(unsigned int size);
void *av_realloc(void *ptr, unsigned int size);
void av_free(void *ptr);
......
......@@ -32,8 +32,8 @@
#include "dsputil.h"
#include "mpegvideo.h"
//#undef NDEBUG
//#include <assert.h>
#undef NDEBUG
#include <assert.h>
#define SQ(a) ((a)*(a))
......@@ -1507,7 +1507,7 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
type = MB_TYPE_FORWARD;
// RAL: No MB_TYPE_DIRECT in MPEG-1 video (only MPEG-4)
if (s->codec_id != CODEC_ID_MPEG1VIDEO && dmin <= score){
if (s->codec_id == CODEC_ID_MPEG4 && dmin <= score){
score = dmin;
type = MB_TYPE_DIRECT;
}
......@@ -1586,8 +1586,9 @@ void ff_fix_long_p_mvs(MpegEncContext * s)
{
const int f_code= s->f_code;
int y, range;
assert(s->pict_type==P_TYPE);
range = (((s->codec_id == CODEC_ID_MPEG1VIDEO) ? 8 : 16) << f_code);
range = (((s->out_format == FMT_MPEG1) ? 8 : 16) << f_code);
if(s->msmpeg4_version) range= 16;
......@@ -1647,7 +1648,7 @@ void ff_fix_long_b_mvs(MpegEncContext * s, int16_t (*mv_table)[2], int f_code, i
int y;
// RAL: 8 in MPEG-1, 16 in MPEG-4
int range = (((s->codec_id == CODEC_ID_MPEG1VIDEO) ? 8 : 16) << f_code);
int range = (((s->out_format == FMT_MPEG1) ? 8 : 16) << f_code);
if(s->avctx->me_range && range > s->avctx->me_range) range= s->avctx->me_range;
......@@ -1673,3 +1674,53 @@ 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<<s->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; y<s->mb_height; y++){
int x;
int xy= (y+1)* (s->mb_width+2)+1;
int i= y*s->mb_width;
for(x=0; x<s->mb_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<num-1; i++){
int s= score[n][i-1] + score[n][i]*2 + score[n][i+1];
if(s > 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
This diff is collapsed.
This diff is collapsed.
......@@ -48,8 +48,13 @@ 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 */
......@@ -385,8 +390,10 @@ typedef struct MpegEncContext {
int me_method; ///< ME algorithm
int scene_change_score;
int mv_dir;
#define MV_DIR_BACKWARD 1
#define MV_DIR_FORWARD 2
#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_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
......@@ -568,6 +575,11 @@ 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
......@@ -644,7 +656,6 @@ typedef struct MpegEncContext {
int repeat_first_field;
int chroma_420_type;
int progressive_frame;
int mpeg2;
int full_pel[2];
int interlaced_dct;
int first_slice;
......@@ -652,7 +663,7 @@ typedef struct MpegEncContext {
/* RTP specific */
/* These are explained on avcodec.h */
int rtp_mode;
int rtp_mode; //FIXME simplify this mess (remove callback, merge mode + payload)
int rtp_payload_size;
void (*rtp_callback)(void *data, int size, int packet_number);
uint8_t *ptr_lastgob;
......@@ -870,6 +881,7 @@ 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,
......
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