X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fdecvobsub.c;h=3b5177ca381fc08a953fd4eabaeab91cf82f71fa;hb=4f0019f03c2e85e8634150ff0c9a31bee6d35ce5;hp=2a5ccab0182442370877cfc011a0fca45f9419b2;hpb=d15b66e85c37cde6ea954b9866f72529a47097fc;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/decvobsub.c b/libhb/decvobsub.c index 2a5ccab0..3b5177ca 100644 --- a/libhb/decvobsub.c +++ b/libhb/decvobsub.c @@ -4,6 +4,26 @@ Homepage: . It may be used under the terms of the GNU General Public License. */ +/* + * Decoder for DVD bitmap subtitles, also known as "VOB subtitles" within the HandBrake source code. + * + * Input format of the subtitle packets is described here: + * http://sam.zoy.org/writings/dvd/subtitles/ + * + * An auxiliary input is the color palette lookup table, in 'subtitle->palette'. + * The demuxer implementation must fill out this table appropriately. + * - In the case of a true DVD input, the palette is read from the IFO file. + * - In the case of an MKV file input, the palette is read from the codec private data of the subtitle track. + * + * Output format of this decoder is PICTURESUB, which is: + * struct PictureSubPacket { + * uint8_t lum[pixelCount]; + * uint8_t alpha[pixelCount]; + * uint8_t chromaU[pixelCount]; + * uint8_t chromaV[pixelCount]; + * } + */ + #include "hb.h" struct hb_work_private_s @@ -42,6 +62,21 @@ int decsubInit( hb_work_object_t * w, hb_job_t * job ) pv->job = job; pv->pts = -1; + + // Warn if the input color palette is empty + int paletteEmpty = 1; + int i; + for (i=0; i<16; i++) + { + if (w->subtitle->palette[i]) + { + paletteEmpty = 0; + break; + } + } + if (paletteEmpty) { + hb_log( "decvobsub: input color palette is empty; not demuxed properly?" ); + } return 0; } @@ -98,6 +133,15 @@ int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, pv->pts = in->start; } } + else + { + // bad size, must have lost sync + // force re-sync + if ( pv->buf != NULL ) + hb_buffer_close( &pv->buf ); + pv->size_sub = 0; + } + } *buf_out = NULL; @@ -127,6 +171,10 @@ int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, void decsubClose( hb_work_object_t * w ) { + hb_work_private_t * pv = w->private_data; + + if ( pv->buf ) + hb_buffer_close( &pv->buf ); free( w->private_data ); } @@ -249,7 +297,7 @@ static void ParseControls( hb_work_object_t * w ) * work, but I get the right colours by doing * no conversion. */ - uint32_t color = title->palette[colors[j]]; + uint32_t color = w->subtitle->palette[colors[j]]; uint8_t Cr, Cb, y; y = (color>>16) & 0xff; Cr = (color>>8) & 0xff; @@ -492,6 +540,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w ) * When forcing subtitles, ignore all those that don't * have the forced flag set. */ + hb_buffer_close( &pv->buf ); return NULL; } @@ -499,7 +548,9 @@ static hb_buffer_t * Decode( hb_work_object_t * w ) { pv->buf->start = pv->pts_start; pv->buf->stop = pv->pts_stop; - return pv->buf; + buf = pv->buf; + pv->buf = NULL; + return buf; } /* Do the actual decoding now */