Commit 1c3990db authored by Michael Niedermayer's avatar Michael Niedermayer

H.261 encoder by (Maarten Daniels <maarten dot daniels at luc dot ac dot be>)

Originally committed as revision 3643 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent d7e2f57f
......@@ -59,6 +59,7 @@ void avcodec_register_all(void)
// register_avcodec(&h264_encoder);
#ifdef CONFIG_RISKY
register_avcodec(&mpeg2video_encoder);
register_avcodec(&h261_encoder);
register_avcodec(&h263_encoder);
register_avcodec(&h263p_encoder);
register_avcodec(&flv_encoder);
......
......@@ -1786,6 +1786,7 @@ extern AVCodec faac_encoder;
extern AVCodec xvid_encoder;
extern AVCodec mpeg1video_encoder;
extern AVCodec mpeg2video_encoder;
extern AVCodec h261_encoder;
extern AVCodec h263_encoder;
extern AVCodec h263p_encoder;
extern AVCodec flv_encoder;
......
This diff is collapsed.
......@@ -88,7 +88,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
qmat = s->q_inter_matrix16[qscale][0];
}
if(s->out_format == FMT_H263 && s->mpeg_quant==0){
if((s->out_format == FMT_H263 || s->out_format == FMT_H261) && s->mpeg_quant==0){
asm volatile(
"movd %%"REG_a", %%mm3 \n\t" // last_non_zero_p1
......
......@@ -279,6 +279,10 @@ void ff_init_me(MpegEncContext *s){
c->hpel_put[2][2]= c->hpel_put[2][3]= zero_hpel;
}
if(s->codec_id == CODEC_ID_H261){
c->sub_motion_search= no_sub_motion_search;
}
c->temp= c->scratchpad;
}
......@@ -691,6 +695,12 @@ static inline void get_limits(MpegEncContext *s, int x, int y)
c->ymin = - y - 16;
c->xmax = - x + s->mb_width *16;
c->ymax = - y + s->mb_height*16;
} else if (s->out_format == FMT_H261){
// Search range of H261 is different from other codec standards
c->xmin = (x > 15) ? - 15 : 0;
c->ymin = (y > 15) ? - 15 : 0;
c->xmax = (x < s->mb_width * 16 - 16) ? 15 : 0;
c->ymax = (y < s->mb_height * 16 - 16) ? 15 : 0;
} else {
c->xmin = - x;
c->ymin = - y;
......
......@@ -221,6 +221,16 @@ static int hpel_motion_search(MpegEncContext * s,
}
#endif
static int no_sub_motion_search(MpegEncContext * s,
int *mx_ptr, int *my_ptr, int dmin,
int src_index, int ref_index,
int size, int h)
{
(*mx_ptr)<<=1;
(*my_ptr)<<=1;
return dmin;
}
int inline ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index,
int ref_index, int size, int h, int add_rate)
{
......
......@@ -1080,6 +1080,11 @@ int MPV_encode_init(AVCodecContext *avctx)
s->low_delay=1;
break;
#ifdef CONFIG_RISKY
case CODEC_ID_H261:
s->out_format = FMT_H261;
avctx->delay=0;
s->low_delay=1;
break;
case CODEC_ID_H263:
if (h263_get_picture_format(s->width, s->height) == 7) {
av_log(avctx, AV_LOG_INFO, "Input picture size isn't suitable for h263 codec! try h263+\n");
......@@ -1199,6 +1204,8 @@ int MPV_encode_init(AVCodecContext *avctx)
#ifdef CONFIG_ENCODERS
#ifdef CONFIG_RISKY
if (s->out_format == FMT_H261)
ff_h261_encode_init(s);
if (s->out_format == FMT_H263)
h263_encode_init(s);
if(s->msmpeg4_version)
......@@ -1215,7 +1222,7 @@ int MPV_encode_init(AVCodecContext *avctx)
if(s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){
s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];
s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i];
}else if(s->out_format == FMT_H263){
}else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){
s->intra_matrix[j] =
s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
}else
......@@ -4127,6 +4134,8 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
msmpeg4_encode_mb(s, s->block, motion_x, motion_y); break;
case CODEC_ID_WMV2:
ff_wmv2_encode_mb(s, s->block, motion_x, motion_y); break;
case CODEC_ID_H261:
ff_h261_encode_mb(s, s->block, motion_x, motion_y); break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
case CODEC_ID_FLV1:
......@@ -4495,15 +4504,21 @@ static int encode_thread(AVCodecContext *c, void *arg){
ff_init_block_index(s);
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
const int xy= mb_y*s->mb_stride + mb_x;
int xy= mb_y*s->mb_stride + mb_x; // removed const, H261 needs to adjust this
int mb_type= s->mb_type[xy];
// int d;
int dmin= INT_MAX;
int dir;
s->mb_x = mb_x;
s->mb_y = mb_y; // moved into loop, can get changed by H.261
ff_update_block_index(s);
if(s->codec_id == CODEC_ID_H261){
ff_h261_reorder_mb_index(s);
xy= s->mb_y*s->mb_stride + s->mb_x;
}
/* write gob / video packet header */
#ifdef CONFIG_RISKY
if(s->rtp_mode){
......@@ -5215,6 +5230,9 @@ static void encode_picture(MpegEncContext *s, int picture_number)
mjpeg_picture_header(s);
break;
#ifdef CONFIG_RISKY
case FMT_H261:
ff_h261_encode_picture_header(s, picture_number);
break;
case FMT_H263:
if (s->codec_id == CODEC_ID_WMV2)
ff_wmv2_encode_picture_header(s, picture_number);
......
......@@ -865,6 +865,12 @@ extern const uint8_t ff_h263_loop_filter_strength[32];
/* h261.c */
void ff_h261_loop_filter(MpegEncContext *s);
void ff_h261_reorder_mb_index(MpegEncContext* s);
void ff_h261_encode_mb(MpegEncContext *s,
DCTELEM block[6][64],
int motion_x, int motion_y);
void ff_h261_encode_picture_header(MpegEncContext * s, int picture_number);
void ff_h261_encode_init(MpegEncContext *s);
/* h263.c, h263dec.c */
......
......@@ -344,6 +344,21 @@ AVInputFormat h261_iformat = {
.value = CODEC_ID_H261,
};
#ifdef CONFIG_ENCODERS
AVOutputFormat h261_oformat = {
"h261",
"raw h261",
"video/x-h261",
"h261",
0,
0,
CODEC_ID_H261,
raw_write_header,
raw_write_packet,
raw_write_trailer,
};
#endif //CONFIG_ENCODERS
AVInputFormat h263_iformat = {
"h263",
"raw h263",
......@@ -648,6 +663,7 @@ int raw_init(void)
av_register_input_format(&dts_iformat);
av_register_input_format(&h261_iformat);
av_register_output_format(&h261_oformat);
av_register_input_format(&h263_iformat);
av_register_output_format(&h263_oformat);
......
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