comparison libmpdemux/demux_y4m.c @ 3800:3080ef830f93

aspect ratio patch by Rik Snel
author alex
date Thu, 27 Dec 2001 19:54:36 +0000
parents f21832490974
children 64f5c5749bad
comparison
equal deleted inserted replaced
3799:f41bbaebcea3 3800:3080ef830f93
114 return 1; 114 return 1;
115 } 115 }
116 116
117 void demux_open_y4m(demuxer_t* demuxer){ 117 void demux_open_y4m(demuxer_t* demuxer){
118 y4m_priv_t* priv = demuxer->priv; 118 y4m_priv_t* priv = demuxer->priv;
119 y4m_ratio_t framerate; 119 y4m_ratio_t ratio;
120 sh_video_t* sh=new_sh_video(demuxer,0); 120 sh_video_t* sh=new_sh_video(demuxer,0);
121 int err; 121 int err;
122 122
123 priv->framenum = 0; 123 priv->framenum = 0;
124 priv->si = malloc(sizeof(y4m_stream_info_t)); 124 priv->si = malloc(sizeof(y4m_stream_info_t));
184 y4m_init_stream_info(priv->si); 184 y4m_init_stream_info(priv->si);
185 if ((err=y4m_read_stream_header(demuxer->stream, priv->si)) != Y4M_OK) 185 if ((err=y4m_read_stream_header(demuxer->stream, priv->si)) != Y4M_OK)
186 mp_msg(MSGT_DEMUXER, MSGL_FATAL, "error parsing YUV4MPEG header: %s\n", y4m_strerr(err)); 186 mp_msg(MSGT_DEMUXER, MSGL_FATAL, "error parsing YUV4MPEG header: %s\n", y4m_strerr(err));
187 187
188 if(!sh->fps) { 188 if(!sh->fps) {
189 framerate = y4m_si_get_framerate(priv->si); 189 ratio = y4m_si_get_framerate(priv->si);
190 if (framerate.d != 0) 190 if (ratio.d != 0)
191 sh->fps=(float)framerate.n/(float)framerate.d; 191 sh->fps=(float)ratio.n/(float)ratio.d;
192 else 192 else
193 sh->fps=15.0f; 193 sh->fps=15.0f;
194 } 194 }
195 sh->frametime=1.0f/sh->fps; 195 sh->frametime=1.0f/sh->fps;
196
197 ratio = y4m_si_get_sampleaspect(priv->si);
198 if (ratio.d != 0 && ratio.n != 0)
199 sh->aspect = (float)ratio.n/(float)ratio.d;
196 200
197 sh->disp_w = y4m_si_get_width(priv->si); 201 sh->disp_w = y4m_si_get_width(priv->si);
198 sh->disp_h = y4m_si_get_height(priv->si); 202 sh->disp_h = y4m_si_get_height(priv->si);
199 } 203 }
200 204
222 sh->bih->biHeight); 226 sh->bih->biHeight);
223 } 227 }
224 228
225 void demux_close_y4m(demuxer_t *demuxer) 229 void demux_close_y4m(demuxer_t *demuxer)
226 { 230 {
227 y4m_priv_t* priv; 231 y4m_priv_t* priv = demuxer->priv;
228 232
229 if (!priv->is_older) 233 if (!priv->is_older)
230 y4m_fini_stream_info(((y4m_priv_t*)demuxer->priv)->si); 234 y4m_fini_stream_info(((y4m_priv_t*)demuxer->priv)->si);
231 free(((y4m_priv_t*)demuxer->priv)->si); 235 free(((y4m_priv_t*)demuxer->priv)->si);
232 free(demuxer->priv); 236 free(demuxer->priv);