comparison libmpcodecs/vd_libmpeg2.c @ 13152:e264e6d6eb76

clenups
author henry
date Thu, 26 Aug 2004 12:07:02 +0000
parents a7542243d695
children cbadd7b190b2
comparison
equal deleted inserted replaced
13151:a46a7abbd01f 13152:e264e6d6eb76
98 98
99 // decode a frame 99 // decode a frame
100 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ 100 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
101 mpeg2dec_t * mpeg2dec = sh->context; 101 mpeg2dec_t * mpeg2dec = sh->context;
102 const mpeg2_info_t * info = mpeg2_info (mpeg2dec); 102 const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
103 mp_image_t* mpi=NULL;
104 int drop_frame, framedrop=flags&3; 103 int drop_frame, framedrop=flags&3;
105 104
106 //MPlayer registers its own draw_slice callback, prevent libmpeg2 from freeing the context 105 //MPlayer registers its own draw_slice callback, prevent libmpeg2 from freeing the context
107 mpeg2dec->decoder.convert=NULL; 106 mpeg2dec->decoder.convert=NULL;
108 mpeg2dec->decoder.convert_id=NULL; 107 mpeg2dec->decoder.convert_id=NULL;
126 while(1){ 125 while(1){
127 int state=mpeg2_parse (mpeg2dec); 126 int state=mpeg2_parse (mpeg2dec);
128 switch(state){ 127 switch(state){
129 case STATE_BUFFER: 128 case STATE_BUFFER:
130 if (mpeg2dec->pending_length) { 129 if (mpeg2dec->pending_length) {
130 // just finished the pending data, continue with processing of the passed buffer
131 mpeg2dec->pending_length = 0; 131 mpeg2dec->pending_length = 0;
132 mpeg2_buffer (mpeg2dec, data, data+len); 132 mpeg2_buffer (mpeg2dec, data, data+len);
133 } else { 133 } else {
134 // parsing of the passed buffer finished, return. 134 // parsing of the passed buffer finished, return.
135 // if(!mpi) fprintf(stderr, "\nNO PICTURE!\n");
136 return 0; 135 return 0;
137 } 136 }
138 break; 137 break;
139 case STATE_SEQUENCE: 138 case STATE_SEQUENCE:
140 // video parameters inited/changed, (re)init libvo: 139 // video parameters inited/changed, (re)init libvo:
163 MP_IMGFLAG_DRAW_CALLBACK:0) 162 MP_IMGFLAG_DRAW_CALLBACK:0)
164 : (MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE), 163 : (MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE),
165 (info->sequence->picture_width+15)&(~15), 164 (info->sequence->picture_width+15)&(~15),
166 (info->sequence->picture_height+15)&(~15) ); 165 (info->sequence->picture_height+15)&(~15) );
167 if(!mpi_new) return 0; // VO ERROR!!!!!!!! 166 if(!mpi_new) return 0; // VO ERROR!!!!!!!!
168 // if (mpi_new == mpi)
169 // fprintf(stderr, "AIEEEEEEEEEE\n");;
170 mpeg2_set_buf(mpeg2dec, mpi_new->planes, mpi_new); 167 mpeg2_set_buf(mpeg2dec, mpi_new->planes, mpi_new);
171 if (info->current_picture->flags&PIC_FLAG_TOP_FIELD_FIRST) 168 if (info->current_picture->flags&PIC_FLAG_TOP_FIELD_FIRST)
172 mpi_new->fields |= MP_IMGFIELD_TOP_FIRST; 169 mpi_new->fields |= MP_IMGFIELD_TOP_FIRST;
173 else mpi_new->fields &= ~MP_IMGFIELD_TOP_FIRST; 170 else mpi_new->fields &= ~MP_IMGFIELD_TOP_FIRST;
174 if (info->current_picture->flags&PIC_FLAG_REPEAT_FIRST_FIELD) 171 if (info->current_picture->flags&PIC_FLAG_REPEAT_FIRST_FIELD)
198 } 195 }
199 case STATE_SLICE: 196 case STATE_SLICE:
200 case STATE_END: 197 case STATE_END:
201 case STATE_INVALID_END: 198 case STATE_INVALID_END:
202 // decoding done: 199 // decoding done:
203 if(mpi) printf("AJAJJJJJJJJ2!\n");
204 if(info->display_fbuf) { 200 if(info->display_fbuf) {
205 mpi=info->display_fbuf->id; 201 mp_image_t* mpi = info->display_fbuf->id;
202 if (mpeg2dec->pending_length == 0) {
206 mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start; 203 mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start;
207 // fprintf(stderr, "pending = %d\n", pending);
208 mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length); 204 mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length);
209 memcpy(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length); 205 memcpy(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length);
206 } else {
207 // still some data in the pending buffer, shouldn't happen
208 mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start;
209 memmove(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length);
210 mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length + len);
211 memcpy(mpeg2dec->pending_buffer+mpeg2dec->pending_length, data, len);
212 mpeg2dec->pending_length += len;
213 }
214 // fprintf(stderr, "pending = %d\n", mpeg2dec->pending_length);
210 return mpi; 215 return mpi;
211 } 216 }
212 } 217 }
213 } 218 }
214 } 219 }