git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13153 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
henry 2004-08-26 12:07:02 +00:00
parent 01a86d251e
commit 2f65cafa17
1 changed files with 12 additions and 7 deletions

View File

@ -100,7 +100,6 @@ static void draw_slice (void * _sh, uint8_t * const * src, unsigned int y){
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
mpeg2dec_t * mpeg2dec = sh->context; mpeg2dec_t * mpeg2dec = sh->context;
const mpeg2_info_t * info = mpeg2_info (mpeg2dec); const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
mp_image_t* mpi=NULL;
int drop_frame, framedrop=flags&3; int drop_frame, framedrop=flags&3;
//MPlayer registers its own draw_slice callback, prevent libmpeg2 from freeing the context //MPlayer registers its own draw_slice callback, prevent libmpeg2 from freeing the context
@ -128,11 +127,11 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
switch(state){ switch(state){
case STATE_BUFFER: case STATE_BUFFER:
if (mpeg2dec->pending_length) { if (mpeg2dec->pending_length) {
// just finished the pending data, continue with processing of the passed buffer
mpeg2dec->pending_length = 0; mpeg2dec->pending_length = 0;
mpeg2_buffer (mpeg2dec, data, data+len); mpeg2_buffer (mpeg2dec, data, data+len);
} else { } else {
// parsing of the passed buffer finished, return. // parsing of the passed buffer finished, return.
// if(!mpi) fprintf(stderr, "\nNO PICTURE!\n");
return 0; return 0;
} }
break; break;
@ -165,8 +164,6 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
(info->sequence->picture_width+15)&(~15), (info->sequence->picture_width+15)&(~15),
(info->sequence->picture_height+15)&(~15) ); (info->sequence->picture_height+15)&(~15) );
if(!mpi_new) return 0; // VO ERROR!!!!!!!! if(!mpi_new) return 0; // VO ERROR!!!!!!!!
// if (mpi_new == mpi)
// fprintf(stderr, "AIEEEEEEEEEE\n");;
mpeg2_set_buf(mpeg2dec, mpi_new->planes, mpi_new); mpeg2_set_buf(mpeg2dec, mpi_new->planes, mpi_new);
if (info->current_picture->flags&PIC_FLAG_TOP_FIELD_FIRST) if (info->current_picture->flags&PIC_FLAG_TOP_FIELD_FIRST)
mpi_new->fields |= MP_IMGFIELD_TOP_FIRST; mpi_new->fields |= MP_IMGFIELD_TOP_FIRST;
@ -200,13 +197,21 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
case STATE_END: case STATE_END:
case STATE_INVALID_END: case STATE_INVALID_END:
// decoding done: // decoding done:
if(mpi) printf("AJAJJJJJJJJ2!\n");
if(info->display_fbuf) { if(info->display_fbuf) {
mpi=info->display_fbuf->id; mp_image_t* mpi = info->display_fbuf->id;
if (mpeg2dec->pending_length == 0) {
mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start; 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); mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length);
memcpy(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length); memcpy(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length);
} else {
// still some data in the pending buffer, shouldn't happen
mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start;
memmove(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length);
mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length + len);
memcpy(mpeg2dec->pending_buffer+mpeg2dec->pending_length, data, len);
mpeg2dec->pending_length += len;
}
// fprintf(stderr, "pending = %d\n", mpeg2dec->pending_length);
return mpi; return mpi;
} }
} }