diff options
author | van <[email protected]> | 2008-11-08 06:50:15 +0000 |
---|---|---|
committer | van <[email protected]> | 2008-11-08 06:50:15 +0000 |
commit | fa63e466c782f2d803cd800148fdfd266d26bfe7 (patch) | |
tree | 52bbc3e91f3ed43ee536c46ca54660a04aedb086 /libhb/internal.h | |
parent | 89eef8d080649cc44a1abc7ed0a0248c6976951d (diff) |
Correct chroma size for raw video frames - width & height need to be rounded up if they're odd before dividing by 2.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1905 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/internal.h')
-rw-r--r-- | libhb/internal.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libhb/internal.h b/libhb/internal.h index a8f5edfd9..3ae1dad79 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -96,6 +96,21 @@ void hb_fifo_push( hb_fifo_t *, hb_buffer_t * ); void hb_fifo_push_head( hb_fifo_t *, hb_buffer_t * ); void hb_fifo_close( hb_fifo_t ** ); +// this routine gets a buffer for an uncompressed YUV420 video frame +// with dimensions width x height. +static inline hb_buffer_t * hb_video_buffer_init( int width, int height ) +{ + // Y requires w x h bytes. U & V each require (w+1)/2 x + // (h+1)/2 bytes (the "+1" is to round up). We shift rather + // than divide by 2 since the compiler can't know these ints + // are positive so it generates very expensive integer divides + // if we do "/2". The code here matches the calculation for + // PIX_FMT_YUV420P in ffmpeg's avpicture_fill() which is required + // for most of HB's filters to work right. + return hb_buffer_init( width * height + ( ( width+1 ) >> 1 ) * + ( ( height+1 ) >> 1 ) * 2 ); +} + /*********************************************************************** * Threads: update.c, scan.c, work.c, reader.c, muxcommon.c **********************************************************************/ |