[Mplayer-cvslog] CVS: main/libmpcodecs vd_libmpeg2.c,1.30,1.31
Jindrich Makovicka CVS
syncmail at mplayerhq.hu
Tue Aug 24 18:15:58 CEST 2004
CVS change done by Jindrich Makovicka CVS
Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var2/tmp/cvs-serv814/libmpcodecs
Modified Files:
vd_libmpeg2.c
Log Message:
libmpeg2 B-frame fix
Index: vd_libmpeg2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_libmpeg2.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- vd_libmpeg2.c 2 Aug 2004 13:09:17 -0000 1.30
+++ vd_libmpeg2.c 24 Aug 2004 16:15:56 -0000 1.31
@@ -63,6 +63,9 @@
sh->context=mpeg2dec;
+ mpeg2dec->pending_buffer = 0;
+ mpeg2dec->pending_length = 0;
+
return 1;
//return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12);
}
@@ -70,16 +73,17 @@
// uninit driver
static void uninit(sh_video_t *sh){
mpeg2dec_t * mpeg2dec = sh->context;
+ if (mpeg2dec->pending_buffer) free(mpeg2dec->pending_buffer);
mpeg2_close (mpeg2dec);
}
-static void draw_slice (void * _sh, uint8_t ** src, unsigned int y){
+static void draw_slice (void * _sh, uint8_t * const * src, unsigned int y){
sh_video_t* sh = (sh_video_t*) _sh;
mpeg2dec_t* mpeg2dec = sh->context;
const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
int stride[3];
-// printf("draw_slice() y=%d \n",y);
+// printf("draw_slice() y=%d \n",y);
stride[0]=mpeg2dec->decoder.stride;
stride[1]=stride[2]=mpeg2dec->decoder.uv_stride;
@@ -107,15 +111,25 @@
((char*)data+len)[3]=0xff;
len+=4;
- mpeg2_buffer (mpeg2dec, data, data+len);
+ if (mpeg2dec->pending_length) {
+ mpeg2_buffer (mpeg2dec, mpeg2dec->pending_buffer, mpeg2dec->pending_buffer + mpeg2dec->pending_length);
+ } else {
+ mpeg2_buffer (mpeg2dec, data, data+len);
+ }
while(1){
int state=mpeg2_parse (mpeg2dec);
switch(state){
case STATE_BUFFER:
- // parsing of the passed buffer finished, return.
-// if(!mpi) printf("\nNO PICTURE!\n");
- return mpi;
+ if (mpeg2dec->pending_length) {
+ mpeg2dec->pending_length = 0;
+ mpeg2_buffer (mpeg2dec, data, data+len);
+ } else {
+ // parsing of the passed buffer finished, return.
+// if(!mpi) fprintf(stderr, "\nNO PICTURE!\n");
+ return 0;
+ }
+ break;
case STATE_SEQUENCE:
// video parameters inited/changed, (re)init libvo:
if(!mpcodecs_config_vo(sh,
@@ -124,7 +138,7 @@
break;
case STATE_PICTURE: {
int type=info->current_picture->flags&PIC_MASK_CODING_TYPE;
- mp_image_t* mpi;
+ mp_image_t* mpi_new;
drop_frame = framedrop && (mpeg2dec->decoder.coding_type == B_TYPE);
drop_frame |= framedrop>=2; // hard drop
@@ -136,37 +150,39 @@
mpeg2_skip(mpeg2dec, 0); //mpeg2skip skips frames until set again to 0
// get_buffer "callback":
- mpi=mpcodecs_get_image(sh,MP_IMGTYPE_IPB,
- (type==PIC_FLAG_CODING_TYPE_B)
+ mpi_new=mpcodecs_get_image(sh,MP_IMGTYPE_IPB,
+ (type==PIC_FLAG_CODING_TYPE_B)
? ((!framedrop && vd_use_slices &&
(info->current_picture->flags&PIC_FLAG_PROGRESSIVE_FRAME)) ?
MP_IMGFLAG_DRAW_CALLBACK:0)
- : (MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE),
+ : (MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE),
(info->sequence->picture_width+15)&(~15),
(info->sequence->picture_height+15)&(~15) );
- if(!mpi) return 0; // VO ERROR!!!!!!!!
- mpeg2_set_buf(mpeg2dec, mpi->planes, mpi);
+ if(!mpi_new) return 0; // VO ERROR!!!!!!!!
+// if (mpi_new == mpi)
+// fprintf(stderr, "AIEEEEEEEEEE\n");;
+ mpeg2_set_buf(mpeg2dec, mpi_new->planes, mpi_new);
if (info->current_picture->flags&PIC_FLAG_TOP_FIELD_FIRST)
- mpi->fields |= MP_IMGFIELD_TOP_FIRST;
- else mpi->fields &= ~MP_IMGFIELD_TOP_FIRST;
+ mpi_new->fields |= MP_IMGFIELD_TOP_FIRST;
+ else mpi_new->fields &= ~MP_IMGFIELD_TOP_FIRST;
if (info->current_picture->flags&PIC_FLAG_REPEAT_FIRST_FIELD)
- mpi->fields |= MP_IMGFIELD_REPEAT_FIRST;
- else mpi->fields &= ~MP_IMGFIELD_REPEAT_FIRST;
- mpi->fields |= MP_IMGFIELD_ORDERED;
+ mpi_new->fields |= MP_IMGFIELD_REPEAT_FIRST;
+ else mpi_new->fields &= ~MP_IMGFIELD_REPEAT_FIRST;
+ mpi_new->fields |= MP_IMGFIELD_ORDERED;
#ifdef MPEG12_POSTPROC
- if(!mpi->qscale){
- mpi->qstride=(info->sequence->picture_width+15)>>4;
- mpi->qscale=malloc(mpi->qstride*((info->sequence->picture_height+15)>>4));
+ if(!mpi_new->qscale){
+ mpi_new->qstride=(info->sequence->picture_width+15)>>4;
+ mpi_new->qscale=malloc(mpi_new->qstride*((info->sequence->picture_height+15)>>4));
}
- mpeg2dec->decoder.quant_store=mpi->qscale;
- mpeg2dec->decoder.quant_stride=mpi->qstride;
- mpi->pict_type=type; // 1->I, 2->P, 3->B
- mpi->qscale_type= 1;
+ mpeg2dec->decoder.quant_store=mpi_new->qscale;
+ mpeg2dec->decoder.quant_stride=mpi_new->qstride;
+ mpi_new->pict_type=type; // 1->I, 2->P, 3->B
+ mpi_new->qscale_type= 1;
#endif
- if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK &&
- !(mpi->flags&MP_IMGFLAG_DIRECT)){
+ if(mpi_new->flags&MP_IMGFLAG_DRAW_CALLBACK &&
+ !(mpi_new->flags&MP_IMGFLAG_DIRECT)){
// nice, filter/vo likes draw_callback :)
mpeg2dec->decoder.convert=draw_slice;
mpeg2dec->decoder.convert_id=sh;
@@ -179,8 +195,14 @@
case STATE_INVALID_END:
// decoding done:
if(mpi) printf("AJAJJJJJJJJ2!\n");
- if(info->display_fbuf) mpi=info->display_fbuf->id;
-// return mpi;
+ if(info->display_fbuf) {
+ mpi=info->display_fbuf->id;
+ mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start;
+// fprintf(stderr, "pending = %d\n", pending);
+ mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length);
+ memcpy(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length);
+ return mpi;
+ }
}
}
}
More information about the MPlayer-cvslog
mailing list