OSDN Git Service

merge 0.9.4 to jp
[handbrake-jp/handbrake-jp.git] / libhb / encvobsub.c
1 /* $Id: envvobsub.c
2
3    This file is part of the HandBrake source code.
4    Homepage: <http://handbrake.fr/>.
5    It may be used under the terms of the GNU General Public License. */
6
7 #include "hb.h"
8
9 struct hb_work_private_s
10 {
11     hb_job_t * job;
12 };
13
14 int encsubInit( hb_work_object_t * w, hb_job_t * job )
15 {
16     hb_work_private_t * pv;
17
18     pv              = calloc( 1, sizeof( hb_work_private_t ) );
19     w->private_data = pv;
20
21     pv->job = job;
22
23     return 0;
24 }
25
26 int encsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
27                 hb_buffer_t ** buf_out )
28 {
29     hb_buffer_t * in = *buf_in;
30
31     if (w->subtitle->source != VOBSUB)
32     {
33         // Invalid source, send EOF, this shouldn't ever happen
34         hb_log("encvobsub: invalid subtitle source");
35         hb_buffer_close( buf_in );
36         *buf_out = hb_buffer_init(0);
37     }
38     if ( in->size <= 0 )
39     {
40         /* EOF on input stream - send it downstream & say that we're done */
41         *buf_out = in;
42         *buf_in = NULL;
43         return HB_WORK_DONE;
44     }
45
46     /*
47      * Not much to do, just pass the buffer on.
48      * Some day, we may re-encode bd subtitles here ;)
49      */
50     if (buf_out)
51     {
52         *buf_out = in;
53         *buf_in = NULL;
54     }
55
56     return HB_WORK_OK; 
57 }
58
59 void encsubClose( hb_work_object_t * w )
60 {
61     free( w->private_data );
62 }
63
64 hb_work_object_t hb_encvobsub =
65 {
66     WORK_ENCVOBSUB,
67     "VOBSUB encoder",
68     encsubInit,
69     encsubWork,
70     encsubClose
71 };