comparison libmpcodecs/vd_libmpeg2.c @ 25977:e3be2de66969

Avoid reinit of vo with the exactly same parameters over and over.
author reimar
date Sat, 16 Feb 2008 14:31:34 +0000
parents afa125da85cf
children 2506f1b0bdbe
comparison
equal deleted inserted replaced
25976:7e297cec88aa 25977:e3be2de66969
30 30
31 typedef struct { 31 typedef struct {
32 mpeg2dec_t *mpeg2dec; 32 mpeg2dec_t *mpeg2dec;
33 int quant_store_idx; 33 int quant_store_idx;
34 char *quant_store[3]; 34 char *quant_store[3];
35 int imgfmt;
36 int width;
37 int height;
38 double aspect;
35 } vd_libmpeg2_ctx_t; 39 } vd_libmpeg2_ctx_t;
36 40
37 // to set/get/query special features/parameters 41 // to set/get/query special features/parameters
38 static int control(sh_video_t *sh,int cmd,void* arg,...){ 42 static int control(sh_video_t *sh,int cmd,void* arg,...){
39 vd_libmpeg2_ctx_t *context = sh->context; 43 vd_libmpeg2_ctx_t *context = sh->context;
155 while(1){ 159 while(1){
156 int state=mpeg2_parse (mpeg2dec); 160 int state=mpeg2_parse (mpeg2dec);
157 int type, use_callback; 161 int type, use_callback;
158 mp_image_t* mpi_new; 162 mp_image_t* mpi_new;
159 unsigned long pw, ph; 163 unsigned long pw, ph;
164 int imgfmt;
160 165
161 switch(state){ 166 switch(state){
162 case STATE_BUFFER: 167 case STATE_BUFFER:
163 if (mpeg2dec->pending_length) { 168 if (mpeg2dec->pending_length) {
164 // just finished the pending data, continue with processing of the passed buffer 169 // just finished the pending data, continue with processing of the passed buffer
174 ph = info->sequence->display_height * info->sequence->pixel_height; 179 ph = info->sequence->display_height * info->sequence->pixel_height;
175 if(ph) sh->aspect = (float) pw / (float) ph; 180 if(ph) sh->aspect = (float) pw / (float) ph;
176 // video parameters initialized/changed, (re)init libvo: 181 // video parameters initialized/changed, (re)init libvo:
177 if (info->sequence->width >> 1 == info->sequence->chroma_width && 182 if (info->sequence->width >> 1 == info->sequence->chroma_width &&
178 info->sequence->height >> 1 == info->sequence->chroma_height) { 183 info->sequence->height >> 1 == info->sequence->chroma_height) {
179 if(!mpcodecs_config_vo(sh, 184 imgfmt = IMGFMT_YV12;
180 info->sequence->picture_width,
181 info->sequence->picture_height, IMGFMT_YV12)) return 0;
182 } else if (info->sequence->width >> 1 == info->sequence->chroma_width && 185 } else if (info->sequence->width >> 1 == info->sequence->chroma_width &&
183 info->sequence->height == info->sequence->chroma_height) { 186 info->sequence->height == info->sequence->chroma_height) {
184 if(!mpcodecs_config_vo(sh, 187 imgfmt = IMGFMT_422P;
185 info->sequence->picture_width,
186 info->sequence->picture_height, IMGFMT_422P)) return 0;
187 } else return 0; 188 } else return 0;
189 if (imgfmt == context->imgfmt &&
190 info->sequence->picture_width == context->width &&
191 info->sequence->picture_height == context->height &&
192 sh->aspect == context->aspect)
193 break;
194 if(!mpcodecs_config_vo(sh,
195 info->sequence->picture_width,
196 info->sequence->picture_height, imgfmt))
197 return 0;
198 context->imgfmt = imgfmt;
199 context->width = info->sequence->picture_width;
200 context->height = info->sequence->picture_height;
201 context->aspect = sh->aspect;
188 break; 202 break;
189 case STATE_PICTURE: 203 case STATE_PICTURE:
190 type=info->current_picture->flags&PIC_MASK_CODING_TYPE; 204 type=info->current_picture->flags&PIC_MASK_CODING_TYPE;
191 205
192 drop_frame = framedrop && (mpeg2dec->decoder.coding_type == B_TYPE); 206 drop_frame = framedrop && (mpeg2dec->decoder.coding_type == B_TYPE);