summaryrefslogtreecommitdiffstats
path: root/libhb/muxmkv.c
diff options
context:
space:
mode:
authorsaintdev <[email protected]>2008-03-20 02:40:02 +0000
committersaintdev <[email protected]>2008-03-20 02:40:02 +0000
commit3a3870d7ea1e81e1a145b1d555b9f0164860f9e3 (patch)
tree9243f518a3d3827ce2d85c28c4c426e22c780a6f /libhb/muxmkv.c
parent1cac31c9ed66396d3fc8a00e9fd75b5f56b000a0 (diff)
Theora.
This adds the theora encoder to the Xcode project as well. It does not enable anything in the Mac GUI, just allows it to build. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1350 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/muxmkv.c')
-rw-r--r--libhb/muxmkv.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/libhb/muxmkv.c b/libhb/muxmkv.c
index 58de30fa1..6ed6a6dec 100644
--- a/libhb/muxmkv.c
+++ b/libhb/muxmkv.c
@@ -106,6 +106,28 @@ static int MKVInit( hb_mux_object_t * m )
track->codecPrivate = job->config.mpeg4.bytes;
track->codecPrivateSize = job->config.mpeg4.length;
break;
+ case HB_VCODEC_THEORA:
+ {
+ int i;
+ uint64_t cp_size = 0;
+ track->codecID = MK_VCODEC_THEORA;
+ uint64_t header_sizes[3];
+ for (i = 0; i < 3; ++i)
+ {
+ ogg_headers[i] = (ogg_packet *)job->config.theora.headers[i];
+ ogg_headers[i]->packet = (unsigned char *)&job->config.theora.headers[i] + sizeof( ogg_packet );
+ header_sizes[i] = ogg_headers[i]->bytes;
+ }
+ track->codecPrivate = mk_laceXiph(header_sizes, 2, &cp_size);
+ track->codecPrivate = realloc(track->codecPrivate, cp_size + ogg_headers[0]->bytes + ogg_headers[1]->bytes + ogg_headers[2]->bytes);
+ for(i = 0; i < 3; ++i)
+ {
+ memcpy(track->codecPrivate + cp_size, ogg_headers[i]->packet, ogg_headers[i]->bytes);
+ cp_size += ogg_headers[i]->bytes;
+ }
+ track->codecPrivateSize = cp_size;
+ }
+ break;
default:
*job->die = 1;
hb_error("muxmkv: Unknown video codec: %x", job->vcodec);
@@ -177,7 +199,7 @@ static int MKVInit( hb_mux_object_t * m )
{
track->codecPrivate = NULL;
track->codecPrivateSize = 0;
- track->codecID = MK_ACODEC_AC3;
+ track->codecID = MK_ACODEC_AC3;
}
else
{
@@ -224,12 +246,14 @@ static int MKVInit( hb_mux_object_t * m )
static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
hb_buffer_t * buf )
{
+ ogg_packet *op = NULL;
hb_job_t * job = m->job;
hb_title_t * title = job->title;
uint64_t timecode = 0;
hb_chapter_t *chapter_data;
char tmp_buffer[1024];
char *string = tmp_buffer;
+
if (mux_data == job->mux_data)
{
/* Video */
@@ -264,6 +288,21 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
}
mux_data->prev_chapter_tc = timecode;
}
+
+ if (job->vcodec == HB_VCODEC_THEORA)
+ {
+ /* ughhh, theora is a pain :( */
+ op = (ogg_packet *)buf->data;
+ op->packet = buf->data + sizeof( ogg_packet );
+ if (mk_startFrame(m->file, mux_data->track) < 0)
+ {
+ hb_error( "Failed to write frame to output file, Disk Full?" );
+ *job->die = 1;
+ }
+ mk_addFrameData(m->file, mux_data->track, op->packet, op->bytes);
+ mk_setFrameFlags(m->file, mux_data->track, timecode, 1);
+ return 0;
+ }
}
else
{
@@ -272,11 +311,13 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
if (job->acodec == HB_ACODEC_VORBIS)
{
/* ughhh, vorbis is a pain :( */
- ogg_packet *op;
-
op = (ogg_packet *)buf->data;
op->packet = buf->data + sizeof( ogg_packet );
- mk_startFrame(m->file, mux_data->track);
+ if (mk_startFrame(m->file, mux_data->track))
+ {
+ hb_error( "Failed to write frame to output file, Disk Full?" );
+ *job->die = 1;
+ }
mk_addFrameData(m->file, mux_data->track, op->packet, op->bytes);
mk_setFrameFlags(m->file, mux_data->track, timecode, 1);
return 0;