}
#endif
-static int h263_decode_init(AVCodecContext *avctx)
+int ff_h263_decode_init(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
s->quant_precision=5;
s->progressive_sequence=1;
s->decode_mb= ff_h263_decode_mb;
+ s->low_delay= 1;
+ avctx->pix_fmt= PIX_FMT_YUV420P;
/* select sub codec */
switch(avctx->codec->id) {
case CODEC_ID_MPEG4:
s->time_increment_bits = 4; /* default value for broken headers */
s->h263_pred = 1;
- s->has_b_frames = 1; //default, might be overriden in the vol header during header parsing
+ s->low_delay = 0; //default, might be overriden in the vol header during header parsing
break;
case CODEC_ID_MSMPEG4V1:
s->h263_msmpeg4 = 1;
return 0;
}
-static int h263_decode_end(AVCodecContext *avctx)
+int ff_h263_decode_end(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
&& (s->workaround_bugs&FF_BUG_AUTODETECT)
&& s->gb.size*8 - get_bits_count(&s->gb) >=0
&& s->gb.size*8 - get_bits_count(&s->gb) < 48
- && !s->resync_marker
+// && !s->resync_marker
&& !s->data_partitioning){
const int bits_count= get_bits_count(&s->gb);
return -1;
}
-static int h263_decode_frame(AVCodecContext *avctx,
+int ff_h263_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
UINT8 *buf, int buf_size)
{
MpegEncContext *s = avctx->priv_data;
int ret,i;
- AVVideoFrame *pict = data;
+ AVFrame *pict = data;
float new_aspect;
#ifdef PRINT_FRAME_TIME
if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix
return -1;
}
-
+
/* let's go :-) */
- if (s->h263_msmpeg4) {
+ if (s->msmpeg4_version==5) {
+ ret= ff_wmv2_decode_picture_header(s);
+ } else if (s->msmpeg4_version) {
ret = msmpeg4_decode_picture_header(s);
} else if (s->h263_pred) {
if(s->avctx->extradata_size && s->picture_number==0){
if(s->flags& CODEC_FLAG_LOW_DELAY)
s->low_delay=1;
-
- s->has_b_frames= !s->low_delay;
} else if (s->h263_intel) {
ret = intel_h263_decode_picture_header(s);
} else {
ret = h263_decode_picture_header(s);
}
- avctx->has_b_frames= s->has_b_frames;
+ avctx->has_b_frames= !s->low_delay;
if(s->workaround_bugs&FF_BUG_AUTODETECT){
if(s->avctx->fourcc == ff_get_fourcc("XVIX"))
if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0)
s->padding_bug_score= 256*256*256*64;
+ if(s->xvid_build && s->xvid_build<=3)
+ s->padding_bug_score= 256*256*256*64;
+
if(s->xvid_build && s->xvid_build<=1)
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
s->current_picture.key_frame= s->pict_type == I_TYPE;
/* skip b frames if we dont have reference frames */
- if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size);
+ if(s->last_picture.data[0]==NULL && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size);
/* skip b frames if we are in a hurry */
if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size);
/* skip everything if we are in a hurry>=5 */
}
if(num_end_markers || error){
fprintf(stderr, "concealing errors\n");
-//printf("type:%d\n", s->pict_type);
ff_error_resilience(s);
}
}
}
#endif
- if(s->pict_type==B_TYPE || (!s->has_b_frames)){
- *pict= *(AVVideoFrame*)&s->current_picture;
+
+ if(s->pict_type==B_TYPE || s->low_delay){
+ *pict= *(AVFrame*)&s->current_picture;
} else {
- *pict= *(AVVideoFrame*)&s->last_picture;
+ *pict= *(AVFrame*)&s->last_picture;
+ }
+
+ if(avctx->debug&FF_DEBUG_QP){
+ int8_t *qtab= pict->qscale_table;
+ int x,y;
+
+ for(y=0; y<s->mb_height; y++){
+ for(x=0; x<s->mb_width; x++){
+ printf("%2d ", qtab[x + y*s->mb_width]);
+ }
+ printf("\n");
+ }
+ printf("\n");
}
/* Return the Picture timestamp as the frame number */
/* we substract 1 because it is added on utils.c */
avctx->frame_number = s->picture_number - 1;
- /* dont output the last pic after seeking
- note we allready added +1 for the current pix in MPV_frame_end(s) */
- if(s->num_available_buffers>=2 || (!s->has_b_frames))
- *data_size = sizeof(AVVideoFrame);
+ /* dont output the last pic after seeking */
+ if(s->last_picture.data[0] || s->low_delay)
+ *data_size = sizeof(AVFrame);
#ifdef PRINT_FRAME_TIME
printf("%Ld\n", rdtsc()-time);
#endif
CODEC_TYPE_VIDEO,
CODEC_ID_MPEG4,
sizeof(MpegEncContext),
- h263_decode_init,
+ ff_h263_decode_init,
NULL,
- h263_decode_end,
- h263_decode_frame,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
};
CODEC_TYPE_VIDEO,
CODEC_ID_H263,
sizeof(MpegEncContext),
- h263_decode_init,
+ ff_h263_decode_init,
NULL,
- h263_decode_end,
- h263_decode_frame,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
};
CODEC_TYPE_VIDEO,
CODEC_ID_MSMPEG4V1,
sizeof(MpegEncContext),
- h263_decode_init,
+ ff_h263_decode_init,
NULL,
- h263_decode_end,
- h263_decode_frame,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
};
CODEC_TYPE_VIDEO,
CODEC_ID_MSMPEG4V2,
sizeof(MpegEncContext),
- h263_decode_init,
+ ff_h263_decode_init,
NULL,
- h263_decode_end,
- h263_decode_frame,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
};
CODEC_TYPE_VIDEO,
CODEC_ID_MSMPEG4V3,
sizeof(MpegEncContext),
- h263_decode_init,
+ ff_h263_decode_init,
NULL,
- h263_decode_end,
- h263_decode_frame,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
};
CODEC_TYPE_VIDEO,
CODEC_ID_WMV1,
sizeof(MpegEncContext),
- h263_decode_init,
- NULL,
- h263_decode_end,
- h263_decode_frame,
- CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
-};
-
-AVCodec wmv2_decoder = {
- "wmv2",
- CODEC_TYPE_VIDEO,
- CODEC_ID_WMV2,
- sizeof(MpegEncContext),
- h263_decode_init,
+ ff_h263_decode_init,
NULL,
- h263_decode_end,
- h263_decode_frame,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
};
CODEC_TYPE_VIDEO,
CODEC_ID_H263I,
sizeof(MpegEncContext),
- h263_decode_init,
+ ff_h263_decode_init,
NULL,
- h263_decode_end,
- h263_decode_frame,
+ ff_h263_decode_end,
+ ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
};