Mercurial > mplayer.hg
comparison libmpcodecs/vd_theora.c @ 34493:da31318562d9
vd_theora: Skip th_decode_ycbcr_out() for packets representing dropped frames.
In case of 0-byte packets we do not need to call th_decode_ycbcr_out() to decode
the frame because we have a duplicated frame, and so we can use the last frame.
patch by Giorgio Vazzana, mywing81 gmail com
author | diego |
---|---|
date | Thu, 19 Jan 2012 14:36:17 +0000 |
parents | 55ff5df09657 |
children | 1c7446e6c426 |
comparison
equal
deleted
inserted
replaced
34492:1495455e6d22 | 34493:da31318562d9 |
---|---|
46 typedef struct theora_struct_st { | 46 typedef struct theora_struct_st { |
47 th_setup_info *tsi; | 47 th_setup_info *tsi; |
48 th_dec_ctx *tctx; | 48 th_dec_ctx *tctx; |
49 th_comment tc; | 49 th_comment tc; |
50 th_info ti; | 50 th_info ti; |
51 th_ycbcr_buffer ycbcrbuf; | |
51 } theora_struct_t; | 52 } theora_struct_t; |
52 | 53 |
53 /** Convert Theora pixelformat to the corresponding IMGFMT_ */ | 54 /** Convert Theora pixelformat to the corresponding IMGFMT_ */ |
54 static uint32_t theora_pixelformat2imgfmt(th_pixel_fmt fmt){ | 55 static uint32_t theora_pixelformat2imgfmt(th_pixel_fmt fmt){ |
55 switch(fmt) { | 56 switch(fmt) { |
167 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags) | 168 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags) |
168 { | 169 { |
169 theora_struct_t *context = sh->context; | 170 theora_struct_t *context = sh->context; |
170 int errorCode = 0; | 171 int errorCode = 0; |
171 ogg_packet op; | 172 ogg_packet op; |
172 th_ycbcr_buffer ycbcrbuf; | |
173 mp_image_t* mpi; | 173 mp_image_t* mpi; |
174 | 174 |
175 // no delayed frames | 175 // no delayed frames |
176 if (!data || !len) | 176 if (!data || !len) |
177 return NULL; | 177 return NULL; |
187 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode packetin failed: %i \n", | 187 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode packetin failed: %i \n", |
188 errorCode); | 188 errorCode); |
189 return NULL; | 189 return NULL; |
190 } | 190 } |
191 | 191 |
192 errorCode = th_decode_ycbcr_out (context->tctx, ycbcrbuf); | 192 if (errorCode != TH_DUPFRAME) { |
193 if (errorCode < 0) | 193 errorCode = th_decode_ycbcr_out(context->tctx, context->ycbcrbuf); |
194 { | 194 if (errorCode != 0) { |
195 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode YUVout failed: %i \n", | 195 mp_msg(MSGT_DECVIDEO, MSGL_ERR, |
196 errorCode); | 196 "Theora decode YUVout failed: %i \n", errorCode); |
197 return NULL; | 197 return NULL; |
198 } | 198 } |
199 | 199 } |
200 mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, ycbcrbuf[0].width, ycbcrbuf[0].height); | 200 |
201 mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, | |
202 context->ycbcrbuf[0].width, | |
203 context->ycbcrbuf[0].height); | |
201 if(!mpi) return NULL; | 204 if(!mpi) return NULL; |
202 | 205 |
203 mpi->planes[0]=ycbcrbuf[0].data; | 206 mpi->planes[0] = context->ycbcrbuf[0].data; |
204 mpi->stride[0]=ycbcrbuf[0].stride; | 207 mpi->stride[0] = context->ycbcrbuf[0].stride; |
205 mpi->planes[1]=ycbcrbuf[1].data; | 208 mpi->planes[1] = context->ycbcrbuf[1].data; |
206 mpi->stride[1]=ycbcrbuf[1].stride; | 209 mpi->stride[1] = context->ycbcrbuf[1].stride; |
207 mpi->planes[2]=ycbcrbuf[2].data; | 210 mpi->planes[2] = context->ycbcrbuf[2].data; |
208 mpi->stride[2]=ycbcrbuf[2].stride; | 211 mpi->stride[2] = context->ycbcrbuf[2].stride; |
209 | 212 |
210 return mpi; | 213 return mpi; |
211 } | 214 } |