# HG changeset patch # User diego # Date 1326983777 0 # Node ID da31318562d9bc4336ba6f7f09942cb4fb502690 # Parent 1495455e6d22e5cd75d1b8dc8b5df98678f3a951 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 diff -r 1495455e6d22 -r da31318562d9 libmpcodecs/vd_theora.c --- a/libmpcodecs/vd_theora.c Thu Jan 19 14:36:15 2012 +0000 +++ b/libmpcodecs/vd_theora.c Thu Jan 19 14:36:17 2012 +0000 @@ -48,6 +48,7 @@ th_dec_ctx *tctx; th_comment tc; th_info ti; + th_ycbcr_buffer ycbcrbuf; } theora_struct_t; /** Convert Theora pixelformat to the corresponding IMGFMT_ */ @@ -169,7 +170,6 @@ theora_struct_t *context = sh->context; int errorCode = 0; ogg_packet op; - th_ycbcr_buffer ycbcrbuf; mp_image_t* mpi; // no delayed frames @@ -189,23 +189,26 @@ return NULL; } - errorCode = th_decode_ycbcr_out (context->tctx, ycbcrbuf); - if (errorCode < 0) - { - mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode YUVout failed: %i \n", - errorCode); - return NULL; - } + if (errorCode != TH_DUPFRAME) { + errorCode = th_decode_ycbcr_out(context->tctx, context->ycbcrbuf); + if (errorCode != 0) { + mp_msg(MSGT_DECVIDEO, MSGL_ERR, + "Theora decode YUVout failed: %i \n", errorCode); + return NULL; + } + } - mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, ycbcrbuf[0].width, ycbcrbuf[0].height); + mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, + context->ycbcrbuf[0].width, + context->ycbcrbuf[0].height); if(!mpi) return NULL; - mpi->planes[0]=ycbcrbuf[0].data; - mpi->stride[0]=ycbcrbuf[0].stride; - mpi->planes[1]=ycbcrbuf[1].data; - mpi->stride[1]=ycbcrbuf[1].stride; - mpi->planes[2]=ycbcrbuf[2].data; - mpi->stride[2]=ycbcrbuf[2].stride; + mpi->planes[0] = context->ycbcrbuf[0].data; + mpi->stride[0] = context->ycbcrbuf[0].stride; + mpi->planes[1] = context->ycbcrbuf[1].data; + mpi->stride[1] = context->ycbcrbuf[1].stride; + mpi->planes[2] = context->ycbcrbuf[2].data; + mpi->stride[2] = context->ycbcrbuf[2].stride; return mpi; }