Exit "Please run ./configure first." ;
}
-HB_VERSION = 0.7.1 ;
-HB_BUILD = 2006022400 ;
+HB_VERSION = 0.7.1a1 ;
+HB_BUILD = 20060923 ;
DEFINES += HB_VERSION=\\\"$(HB_VERSION)\\\" HB_BUILD=$(HB_BUILD) ;
LANGUAGES = fr de it pl ru nl es pt ja ;
RM = rm -rf ;
actions LibAvCodec
{
cd `dirname $(>)` && CONTRIB=`pwd` &&
- rm -rf ffmpeg-20060326 && tar xzf ffmpeg.tar.gz &&
- cd ffmpeg-20060326 && $(FFMPEG_PATCH) &&
+ rm -rf ffmpeg && tar xzf ffmpeg.tar.gz &&
+ cd ffmpeg && $(FFMPEG_PATCH) &&
./configure --prefix=$CONTRIB $(FFMPEG_OPTIONS) --enable-gpl --disable-audio-beos &&
make lib && make install-libs install-headers &&
strip -S $CONTRIB/lib/libavcodec.a
# libdvdread
rule LibDvdRead
{
+ LIBDVDREAD_PATCH = "patch -p1 < ../patch-libdvdread.patch" ;
Depends $(<) : $(>) ;
Depends lib : $(<) ;
}
{
cd `dirname $(>)` && CONTRIB=`pwd` &&
rm -rf libdvdread && tar xzf libdvdread.tar.gz && cd libdvdread &&
+ $(LIBDVDREAD_PATCH) &&
./configure --prefix=$CONTRIB --disable-shared --with-libdvdcss=$CONTRIB &&
make && make install &&
strip -S $CONTRIB/lib/libdvdread.a
# libx264
rule LibX264
{
+ LIBX264_PATCH = "" ;
+ if $(OS) = MACOSX && $(OSPLAT) = X86
+ {
+ LIBX264_PATCH = " patch -p1 < ../patch-x264-macintel.patch && " ;
+ }
Depends $(<) : $(>) ;
Depends lib : $(<) ;
}
actions LibX264
{
cd `dirname $(>)` && CONTRIB=`pwd` &&
- rm -rf x264 && tar xzf x264.tar.gz && cd x264 &&
+ rm -rf x264 && tar xzf x264.tar.gz && cd x264 && $(LIBX264_PATCH)
./configure --prefix=$CONTRIB --enable-pthread && make &&
make install &&
strip -S $CONTRIB/lib/libx264.a
{
cd `dirname $(>)` && CONTRIB=`pwd` &&
rm -rf xvidcore && tar xzf xvidcore.tar.gz &&
- cd xvidcore && patch -p1 < ../xvidcore.patch &&
+ cd xvidcore && patch -p1 < ../patch-xvidcore.patch &&
cd build/generic/ && ./configure && make libxvidcore.a &&
cp ./=build/libxvidcore.a $CONTRIB/lib/ &&
cp ../../src/xvid.h $CONTRIB/include/ &&
-diff -ru ffmpeg-20060326-bak/configure ffmpeg-20060326/configure
---- ffmpeg-20060326-bak/configure 2006-03-26 22:04:53.000000000 +0200
-+++ ffmpeg-20060326/configure 2006-04-26 16:48:00.000000000 +0200
-@@ -272,7 +272,7 @@
+--- ffmpeg/configure 2006-09-23 14:22:08.000000000 -0400
++++ ffmpeg-patched/configure 2006-09-23 14:37:49.000000000 -0400
+@@ -493,7 +493,7 @@
2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
mmx="no"
;;
-*20010315*) echo "BeBits gcc"
+*20010315*|2.95.3*) echo "BeBits gcc"
- CFLAGS="$CFLAGS -fno-expensive-optimizations"
+ add_cflags "-fno-expensive-optimizations"
;;
esac
-diff -ru ffmpeg-20060326-bak/libavformat/movenc.c ffmpeg-20060326/libavformat/movenc.c
---- ffmpeg-20060326-bak/libavformat/movenc.c 2006-03-26 22:04:53.000000000 +0200
-+++ ffmpeg-20060326/libavformat/movenc.c 2006-04-26 16:48:54.000000000 +0200
-@@ -22,6 +22,10 @@
- #include "avio.h"
- #include "mov.h"
+--- ffmpeg/libavformat/movenc.c 2006-09-23 14:22:08.000000000 -0400
++++ ffmpeg-patched/libavformat/movenc.c 2006-09-23 14:49:42.000000000 -0400
+@@ -34,6 +34,7 @@
+ #define MODE_PSP 3 // example working PSP command line:
+ // ffmpeg -i testinput.avi -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 M4V00001.MP4
+ #define MODE_3G2 4
++#define MODE_IPOD 5
-+#ifndef UINT32_MAX
-+#define UINT32_MAX (4294967295U)
-+#endif
-+
- #undef NDEBUG
- #include <assert.h>
-
-@@ -435,11 +439,6 @@
- end = track->vosData + track->vosLen;
-
- put_byte(pb, 1); /* version */
-- put_byte(pb, 77); /* profile */
-- put_byte(pb, 64); /* profile compat */
-- put_byte(pb, 30); /* level */
-- put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-- put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-
- /* look for sps and pps */
- while (buf < end) {
-@@ -458,6 +457,12 @@
- }
- assert(sps);
- assert(pps);
-+
-+ put_byte(pb, sps[1]); /* profile */
-+ put_byte(pb, sps[2]); /* profile compat */
-+ put_byte(pb, sps[3]); /* level */
-+ put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-+ put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
- put_be16(pb, sps_size);
- put_buffer(pb, sps, sps_size);
- put_byte(pb, 1); /* number of pps */
-@@ -621,6 +626,18 @@
+ typedef struct MOVIentry {
+ unsigned int flags, size;
+@@ -600,6 +601,18 @@
return tag;
}
+static int mov_write_colr_tag(ByteIOContext *pb)
+{
-+ put_be32( pb, 0x12 );
-+ put_tag( pb, "colr" );
-+ put_tag( pb, "nclc" );
-+ put_be16( pb, 6 );
-+ put_be16( pb, 1 );
-+ put_be16( pb, 6 );
-+ put_be32( pb, 0 );
-+ return 0x12;
++ put_be32( pb, 0x12 );
++ put_tag( pb, "colr" );
++ put_tag( pb, "nclc" );
++ put_be16( pb, 6 );
++ put_be16( pb, 1 );
++ put_be16( pb, 6 );
++ put_be32( pb, 0 );
++ return 0x12;
+}
+
static int mov_write_video_tag(ByteIOContext *pb, MOVTrack* track)
{
offset_t pos = url_ftell(pb);
-@@ -670,6 +687,8 @@
- else if(track->enc->codec_id == CODEC_ID_H264)
- mov_write_avcc_tag(pb, track);
-
-+ mov_write_colr_tag(pb);
+@@ -649,8 +662,21 @@
+ mov_write_d263_tag(pb);
+ else if(track->enc->codec_id == CODEC_ID_SVQ3)
+ mov_write_svq3_tag(pb);
+- else if(track->enc->codec_id == CODEC_ID_H264)
+- mov_write_avcc_tag(pb, track);
++ else if(track->enc->codec_id == CODEC_ID_H264) {
++ mov_write_avcc_tag(pb, track);
++ if (track->mode == MODE_IPOD) {
++ put_be32(pb, 0x1C); /* size ... reports as 28 in mp4box! */
++ put_tag(pb, "uuid");
++ put_be32(pb, 0x6B6840F2);
++ put_be32(pb, 0x5F244FC5);
++ put_be32(pb, 0xBA39A51B);
++ put_be32(pb, 0xCF0323F3);
++ put_be32(pb, 0x00000001);
++ put_be32(pb, 0x0000039C);
++ }
++ }
+
++ mov_write_colr_tag(pb);
+
return updateSize (pb, pos);
}
+@@ -903,6 +929,10 @@
+ /* Track width and height, for visual only */
+ if(track->enc->codec_type == CODEC_TYPE_VIDEO) {
+ double sample_aspect_ratio = av_q2d(track->enc->sample_aspect_ratio);
++ if (track->mode == MODE_IPOD) {
++ /* FIXME , I do not believe this is needed, bad assumption */
++ sample_aspect_ratio = 1;
++ }
+ if( !sample_aspect_ratio ) sample_aspect_ratio = 1;
+ put_be32(pb, sample_aspect_ratio * track->enc->width*0x10000);
+ put_be32(pb, track->enc->height*0x10000);
+@@ -1348,6 +1378,8 @@
+ put_tag(pb, "MSNV");
+ else if ( mov->mode == MODE_MP4 )
+ put_tag(pb, "isom");
++ else if ( mov->mode == MODE_IPOD )
++ put_tag(pb, "isom");
+ else
+ put_tag(pb, "qt ");
-diff -ru ffmpeg-20060326-bak/libavformat/tcp.c ffmpeg-20060326/libavformat/tcp.c
---- ffmpeg-20060326-bak/libavformat/tcp.c 2006-03-26 22:04:53.000000000 +0200
-+++ ffmpeg-20060326/libavformat/tcp.c 2006-04-26 16:48:00.000000000 +0200
+@@ -1359,6 +1391,8 @@
+ put_tag(pb, "3g2a");
+ else if ( mov->mode == MODE_PSP )
+ put_tag(pb, "MSNV");
++ else if ( mov->mode == MODE_IPOD )
++ put_tag(pb, "mp41");
+ else if ( mov->mode == MODE_MP4 )
+ put_tag(pb, "mp41");
+ else
+@@ -1440,7 +1474,8 @@
+ else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3G2;
+ else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
+ else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
+-
++ else if (!strcmp("ipod", s->oformat->name)) mov->mode = MODE_IPOD;
++
+ mov_write_ftyp_tag(pb,s);
+ if ( mov->mode == MODE_PSP ) {
+ if ( s->nb_streams != 2 ) {
+@@ -1640,6 +1675,21 @@
+ .flags = AVFMT_GLOBALHEADER,
+ };
+ #endif
++#ifdef CONFIG_IPOD_MUXER
++AVOutputFormat ipod_muxer = {
++ "ipod",
++ "ipod mp4 format",
++ "application/mp4",
++ "mp4,m4v,ipod",
++ sizeof(MOVContext),
++ CODEC_ID_AAC,
++ CODEC_ID_MPEG4,
++ mov_write_header,
++ mov_write_packet,
++ mov_write_trailer,
++ .flags = AVFMT_GLOBALHEADER,
++};
++#endif
+ #ifdef CONFIG_PSP_MUXER
+ AVOutputFormat psp_muxer = {
+ "psp",
+--- ffmpeg/libavformat/tcp.c 2006-09-23 14:22:08.000000000 -0400
++++ ffmpeg-patched/libavformat/tcp.c 2006-09-23 14:34:32.000000000 -0400
@@ -112,11 +112,13 @@
break;
}
}
s->fd = fd;
return 0;
+--- ffmpeg/libavformat/allformats.h 2006-09-23 14:22:08.000000000 -0400
++++ ffmpeg-patched/libavformat/allformats.h 2006-09-23 15:02:41.000000000 -0400
+@@ -74,6 +74,7 @@
+ extern AVOutputFormat mov_muxer;
+ extern AVOutputFormat tgp_muxer;
+ extern AVOutputFormat mp4_muxer;
++extern AVOutputFormat ipod_muxer;
+ extern AVOutputFormat psp_muxer;
+ extern AVOutputFormat tg2_muxer;
+ extern AVInputFormat mp3_demuxer;
+--- ffmpeg/libavformat/allformats.c 2006-09-23 14:22:08.000000000 -0400
++++ ffmpeg-patched/libavformat/allformats.c 2006-09-23 14:26:11.000000000 -0400
+@@ -204,6 +204,9 @@
+ #ifdef CONFIG_PSP_MUXER
+ av_register_output_format(&psp_muxer);
+ #endif
++#ifdef CONFIG_IPOD_MUXER
++ av_register_output_format(&ipod_muxer);
++#endif
+ #ifdef CONFIG_TG2_MUXER
+ av_register_output_format(&tg2_muxer);
+ #endif
+--- ffmpeg/libavformat/Makefile 2006-09-23 14:22:08.000000000 -0400
++++ ffmpeg-patched/libavformat/Makefile 2006-09-23 20:15:09.000000000 -0400
+@@ -62,6 +62,7 @@
+ OBJS-$(CONFIG_TGP_MUXER) += movenc.o riff.o isom.o
+ OBJS-$(CONFIG_MP4_MUXER) += movenc.o riff.o isom.o
+ OBJS-$(CONFIG_PSP_MUXER) += movenc.o riff.o isom.o
++OBJS-$(CONFIG_IPOD_MUXER) += movenc.o riff.o isom.o
+ OBJS-$(CONFIG_TG2_MUXER) += movenc.o riff.o isom.o
+ OBJS-$(CONFIG_MP3_DEMUXER) += mp3.o
+ OBJS-$(CONFIG_MP2_MUXER) += mp3.o
--- /dev/null
+--- libdvdread/dvdread/nav_read.c 2005-09-05 22:11:16.000000000 -0400
++++ libdvdread-patched/dvdread/nav_read.c 2006-09-23 14:14:43.000000000 -0400
+@@ -204,6 +204,6 @@
+ /* Asserts */
+
+ /* dsi dsi gi */
+- CHECK_VALUE(dsi->dsi_gi.zero1 == 0);
++// CHECK_VALUE(dsi->dsi_gi.zero1 == 0);
+ }
+
--- /dev/null
+--- x264/common/i386/i386inc.asm 2006-09-23 14:01:05.000000000 -0400
++++ x264-patched/common/i386/i386inc.asm 2006-09-24 09:21:27.000000000 -0400
+@@ -40,12 +40,12 @@
+ ; is unable to compute address offsets outside of .text so we use the .text
+ ; section instead until NASM is fixed.
+ %macro SECTION_RODATA 0
+- %ifidn __OUTPUT_FORMAT__,macho
+- SECTION .text
+- fakegot:
+- %else
++; %ifidn __OUTPUT_FORMAT__,macho
++; SECTION .text
++; fakegot:
++; %else
+ SECTION .rodata data align=16
+- %endif
++; %endif
+ %endmacro
+
+ ; PIC support macros. All these macros are totally harmless when __PIC__ is
+--- x264/common/i386/predict-a.asm 2006-09-23 14:01:05.000000000 -0400
++++ x264-patched/common/i386/predict-a.asm 2006-09-24 09:21:27.000000000 -0400
+@@ -191,7 +191,6 @@
+ %assign Y (Y-1)
+ movq [edx + Y*FDEC_STRIDE], mm1
+
+- picpop ebx
+ ret
+
+ ;-----------------------------------------------------------------------------
+@@ -228,7 +227,6 @@
+ %assign Y (Y-1)
+ movq [edx + Y*FDEC_STRIDE], mm0
+
+- picpop ebx
+ ret
+
+ ;-----------------------------------------------------------------------------
+@@ -269,8 +267,7 @@
+ %endrep
+ movq [edx + Y *FDEC_STRIDE], mm3
+ movq [edx + (Y+1)*FDEC_STRIDE], mm0
+-
+- picpop ebx
++
+ ret
+
+ ;-----------------------------------------------------------------------------
-http://download.m0k.org/handbrake/contrib/a52dec-0.7.4.tar.gz
+http://multics.dynalias.com/handbrake/contrib/a52dec-0.7.4.tar.gz
-http://download.m0k.org/handbrake/contrib/faac-1.24.tar.gz
+http://multics.dynalias.com/handbrake/contrib/faac-1.24.tar.gz
-http://download.m0k.org/handbrake/contrib/ffmpeg-20060326.tar.gz
+http://multics.dynalias.com/handbrake/contrib/ffmpeg-6324.tar.gz
-http://download.m0k.org/handbrake/contrib/lame-3.96.1.tar.gz
+http://multics.dynalias.com/handbrake/contrib/lame-3.96.1.tar.gz
-http://download.m0k.org/handbrake/contrib/libdvdcss-1.2.9.tar.gz
+http://multics.dynalias.com/handbrake/contrib/libdvdcss-1.2.9.tar.gz
-http://download.m0k.org/handbrake/contrib/libdvdread-20050928.tar.gz
+http://multics.dynalias.com/handbrake/contrib/libdvdread-20050928.tar.gz
-http://download.m0k.org/handbrake/contrib/libogg-1.1.2.tar.gz
+http://multics.dynalias.com/handbrake/contrib/libogg-1.1.2.tar.gz
-http://download.m0k.org/handbrake/contrib/libsamplerate-0.1.2.tar.gz
+http://multics.dynalias.com/handbrake/contrib/libsamplerate-0.1.2.tar.gz
-http://download.m0k.org/handbrake/contrib/libvorbis-1.1.1.tar.gz
+http://multics.dynalias.com/handbrake/contrib/libvorbis-1.1.1.tar.gz
-http://download.m0k.org/handbrake/contrib/mpeg2dec-20051112.tar.gz
+http://multics.dynalias.com/handbrake/contrib/mpeg2dec-20051112.tar.gz
-http://download.m0k.org/handbrake/contrib/x264-r401.tar.gz
+http://multics.dynalias.com/handbrake/contrib/x264-r568.tar.gz
-http://download.m0k.org/handbrake/contrib/xvidcore-1.1.0.tar.gz
+http://multics.dynalias.com/handbrake/contrib/xvidcore-1.1.0.tar.gz
{
case HB_MUX_MP4:
case HB_MUX_PSP:
+ case HB_MUX_IPOD:
overhead = 6;
break;
case HB_MUX_AVI:
#define HB_VCODEC_FFMPEG 0x000001
#define HB_VCODEC_XVID 0x000002
#define HB_VCODEC_X264 0x000004
+
int vcodec;
float vquality;
int vbitrate;
int vrate_base;
int pass;
int h264_13;
+ int h264_level;
/* Audio tracks:
Indexes in hb_title_t's audios list, starting from 0.
#define HB_MUX_PSP 0x020000
#define HB_MUX_AVI 0x040000
#define HB_MUX_OGM 0x080000
+#define HB_MUX_IPOD 0x100000
+
int mux;
char * file;
title->cell_end, title->block_start, title->block_end,
title->block_count );
- if( title->block_count < 2048 )
+ if( title->block_count < 2048 )
{
hb_log( "scan: title too short (%d blocks), ignoring",
title->block_count );
/* $Id: encx264.c,v 1.21 2005/11/04 13:09:41 titer Exp $
- This file is part of the HandBrake source code.
- Homepage: <http://handbrake.m0k.org/>.
- It may be used under the terms of the GNU General Public License. */
+This file is part of the HandBrake source code.
+Homepage: <http://handbrake.m0k.org/>.
+It may be used under the terms of the GNU General Public License. */
#include <stdarg.h>
x264_t * x264;
x264_picture_t pic_in;
x264_picture_t pic_out;
-
+
char filename[1024];
};
/***********************************************************************
- * hb_work_encx264_init
- ***********************************************************************
- *
- **********************************************************************/
+* hb_work_encx264_init
+***********************************************************************
+*
+**********************************************************************/
int encx264Init( hb_work_object_t * w, hb_job_t * job )
{
x264_param_t param;
x264_nal_t * nal;
int nal_count;
int i, size;
-
+
hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) );
w->private_data = pv;
-
+
pv->job = job;
-
+
memset( pv->filename, 0, 1024 );
hb_get_tempory_filename( job->h, pv->filename, "x264.log" );
-
+
x264_param_default( ¶m );
-
+
param.i_threads = hb_get_cpu_count();
param.i_width = job->width;
param.i_height = job->height;
param.i_fps_den = job->vrate_base;
param.i_keyint_max = 20 * job->vrate / job->vrate_base;
param.i_log_level = X264_LOG_NONE;
- if( job->h264_13 )
+
+ if( job->h264_level )
{
- param.i_threads = 1;
- param.b_cabac = 0;
- param.i_level_idc = 13;
+ param.i_threads = 1;
+ param.b_cabac = 0;
+ param.i_level_idc = job->h264_level;
+ hb_log( "encx264: encoding at level %i",
+ param.i_level_idc );
}
-
+
/* Slightly faster with minimal quality lost */
param.analyse.i_subpel_refine = 4;
-
+
if( job->vquality >= 0.0 && job->vquality <= 1.0 )
{
/* Constant QP */
}
else
{
- /* Rate control */
- param.rc.b_cbr = 1;
+
+ /* Rate control */
+ /* no longer in x264 - see rc.i_rc_method in x264.h */
+ /* param.rc.b_cbr = 1; */
+
+ /* these were the only settings I could use to get accurate ending video bitrate */
+ param.rc.i_rc_method = X264_RC_CRF;
+ param.rc.i_vbv_max_bitrate = job->vbitrate;
+ param.rc.i_vbv_buffer_size = 224;
+ param.rc.i_rf_constant = 1;
+
param.rc.i_bitrate = job->vbitrate;
switch( job->pass )
{
case 1:
+ param.rc.i_rc_method = X264_RC_ABR;
param.rc.b_stat_write = 1;
param.rc.psz_stat_out = pv->filename;
break;
case 2:
+ param.rc.i_rc_method = X264_RC_ABR;
param.rc.b_stat_read = 1;
param.rc.psz_stat_in = pv->filename;
break;
}
}
-
+
hb_log( "encx264: opening libx264 (pass %d)", job->pass );
pv->x264 = x264_encoder_open( ¶m );
-
+
w->config->mpeg4.length = 0;
-
+
x264_encoder_headers( pv->x264, &nal, &nal_count );
-
+
for( i = 0; i < nal_count; i++ )
{
size = sizeof( w->config->mpeg4.bytes ) - w->config->mpeg4.length;
&size, 1, &nal[i] );
w->config->mpeg4.length += size;
}
-
+
x264_picture_alloc( &pv->pic_in, X264_CSP_I420,
job->width, job->height );
-
+
return 0;
}
{
hb_work_private_t * pv = w->private_data;
x264_encoder_close( pv->x264 );
-
+
/* TODO */
}
int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
- hb_buffer_t ** buf_out )
+ hb_buffer_t ** buf_out )
{
hb_work_private_t * pv = w->private_data;
hb_job_t * job = pv->job;
int i_nal;
x264_nal_t * nal;
int i;
-
+
/* XXX avoid this memcpy ? */
memcpy( pv->pic_in.img.plane[0], in->data, job->width * job->height );
if( job->grayscale )
memcpy( pv->pic_in.img.plane[2], in->data + 5 * job->width *
job->height / 4, job->width * job->height / 4 );
}
-
+
pv->pic_in.i_type = X264_TYPE_AUTO;
pv->pic_in.i_qpplus1 = 0;
-
+
x264_encoder_encode( pv->x264, &nal, &i_nal,
&pv->pic_in, &pv->pic_out );
-
+
+
+
/* Should be way too large */
buf = hb_buffer_init( 3 * job->width * job->height / 2 );
buf->start = in->start;
buf->stop = in->stop;
buf->key = ( pv->pic_out.i_type == X264_TYPE_IDR );
-
+
+
buf->size = 0;
for( i = 0; i < i_nal; i++ )
{
buf->size += size;
}
}
-
+
*buf_out = buf;
-
+
return HB_WORK_OK;
}
{
case HB_MUX_MP4:
case HB_MUX_PSP:
+ case HB_MUX_IPOD:
m = hb_mux_mp4_init( job );
break;
case HB_MUX_AVI:
/* $Id: muxmp4.c,v 1.24 2005/11/04 13:09:41 titer Exp $
- This file is part of the HandBrake source code.
- Homepage: <http://handbrake.m0k.org/>.
- It may be used under the terms of the GNU General Public License. */
+This file is part of the HandBrake source code.
+Homepage: <http://handbrake.m0k.org/>.
+It may be used under the terms of the GNU General Public License. */
#include <ffmpeg/avformat.h>
#include "hb.h"
int64_t ff_gcd(int64_t a, int64_t b);
-static inline int ff_get_fourcc(const char *s)
-{
- return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24);
-}
struct hb_mux_object_s
{
HB_MUX_COMMON;
-
+
hb_job_t * job;
-
+
AVFormatContext * format;
};
};
/**********************************************************************
- * MP4Init
- **********************************************************************
- * Allocates hb_mux_data_t structures, create file and write headers
- *********************************************************************/
+* MP4Init
+**********************************************************************
+* Allocates hb_mux_data_t structures, create file and write headers
+*********************************************************************/
static int MP4Init( hb_mux_object_t * m )
{
hb_job_t * job = m->job;
AVFormatContext * oc;
AVStream *st;
AVFormatParameters params;
-
+
register_protocol(&file_protocol);
- movenc_init();
-
+ //movenc_init();
+ av_register_all();
+
oc = av_alloc_format_context();
-
+
if( job->mux & HB_MUX_PSP )
{
oc->oformat = guess_format( "psp", NULL, NULL );
+ hb_log( "using format psp" );
+ }
+ else if( job->mux & HB_MUX_IPOD )
+ {
+ /* added this format to ffmpeg source */
+ oc->oformat = guess_format( "ipod", NULL, NULL );
+ hb_log( "using format ipod" );
}
else
{
oc->oformat = guess_format( "mp4", NULL, NULL );
+ hb_log( "using format mp4" );
}
if( !oc->oformat )
{
hb_log( "guess_format failed" );
return 1;
}
+
+ hb_log( "using oformat: %s", oc->oformat->name );
+
snprintf( oc->filename, sizeof( oc->filename ),
"%s", job->file );
-
+
st = av_new_stream( oc, oc->nb_streams );
if( !st )
{
st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = ( job->vcodec == HB_VCODEC_X264 ) ?
- CODEC_ID_H264 : CODEC_ID_MPEG4;
+CODEC_ID_H264 : CODEC_ID_MPEG4;
st->codec->extradata= job->config.mpeg4.bytes;
st->codec->extradata_size= job->config.mpeg4.length;
st->codec->bit_rate = 1000 * job->vbitrate;
i = ff_gcd( job->vrate_base, job->vrate );
st->codec->time_base = (AVRational){ job->vrate_base / i, job->vrate / i };
-
+
st->codec->pix_fmt = PIX_FMT_YUV420P;
st->codec->width = job->width;
st->codec->height = job->height;
st->codec->has_b_frames = 0;
-
+
job->mux_data = malloc( sizeof( hb_mux_data_t ) );
job->mux_data->track = 0;
-
+
for( i = 0; i < hb_list_count( title->list_audio ); i++ )
{
audio = hb_list_item( title->list_audio, i );
-
+
audio->mux_data = malloc( sizeof( hb_mux_data_t ) );
audio->mux_data->track = i + 1;
-
+
st = av_new_stream( oc, oc->nb_streams );
if( !st )
{
st->codec->frame_size = 1024;
st->codec->block_align = 0;
}
-
+
oc->timestamp = 0;
if( url_fopen( &oc->pb, job->file, URL_WRONLY ) < 0 )
{
hb_log( "url_fopen failed (%s)", job->file );
return 1;
}
-
+
memset( ¶ms, 0, sizeof( params ) );
if( av_set_parameters( oc, ¶ms ) < 0 )
{
hb_log( "av_set_parameters failed" );
return 1;
}
-
+
oc->packet_size= 0;
oc->mux_rate= 0;
oc->preload= (int)(0.5*AV_TIME_BASE);
oc->max_delay= (int)(0.7*AV_TIME_BASE);
oc->loop_output = AVFMT_NOOUTPUTLOOP;
-
+
if( av_write_header( oc ) < 0 )
{
hb_log( "av_write_header failed" );
return 1;
}
-
+
m->format = oc;
-
+
return 0;
}
{
AVPacket pkt;
av_init_packet(&pkt);
-
+
pkt.stream_index = mux_data->track;
pkt.data = buf->data;
pkt.size = buf->size;
pkt.pts = buf->start;
-
+
if( buf->key )
{
pkt.flags |= PKT_FLAG_KEY;
}
-
+
av_interleaved_write_frame( m->format, &pkt );
-
+
return 0;
}
av_write_trailer( m->format );
url_fclose( &m->format->pb );
av_free( m->format );
-
+
return 0;
}
SetWLE ( &h.i_bits_per_sample, 0 );
SetDWLE( &h.header.video.i_width, job->width );
SetDWLE( &h.header.video.i_height, job->height );
- op.packet = (char*)&h;
+ op.packet = (unsigned char*)&h;
op.bytes = sizeof( ogg_stream_header_t );
op.b_o_s = 1;
op.e_o_s = 0;
mpeg2 = hb_libmpeg2_init();
- for( j = 0; j < 10240; j++ )
+ for( j = 0; j < 10240 ; j++ )
{
if( !hb_dvd_read( data->dvd, buf_ps ) )
{
}
if( job->vcodec & HB_VCODEC_X264 )
{
+ switch([fVidEncoderPopUp indexOfSelectedItem]) {
+ case 1:
+ /* Baseline Level 1.3
+ For iPods pre firmware 1.2 */
+ job->h264_level = 13;
+ break;
+ case 2:
+ /* Baseline Level 3.0
+ For iPods w/ fimware 1.2 */
+ job->h264_level = 30;
+ job->mux = HB_MUX_IPOD;
+ break;
+ }
job->h264_13 = [fVidEncoderPopUp indexOfSelectedItem];
}
/* MPEG-4 -> H.264 */
[fVidEncoderPopUp removeAllItems];
[fVidEncoderPopUp addItemWithTitle: @"x264 (Main profile)"];
- [fVidEncoderPopUp addItemWithTitle: @"x264 (Baseline profile)"];
+ [fVidEncoderPopUp addItemWithTitle: @"x264 (Baseline profile level 1.3)"];
+ [fVidEncoderPopUp addItemWithTitle: @"x264 (Baseline profile level 3.0)"];
}
else if( ( FormatSettings[format][codecs] & HB_VCODEC_FFMPEG ) )
{
static int grayscale = 0;
static int vcodec = HB_VCODEC_FFMPEG;
static int h264_13 = 0;
+static int h264_30 = 0;
static char * audios = NULL;
static int sub = 0;
static int width = 0;
}
if( h264_13 )
{
- job->h264_13 = h264_13;
- }
+ job->h264_level = 13;
+ }
+ if( h264_30 )
+ {
+ job->h264_level = 30;
+ }
if( vrate )
{
job->vrate = 27000000;
"\n"
" -s, --subtitle <number> Select subtitle (default: none)\n"
" -e, --encoder <string> Set video library encoder (ffmpeg,xvid,\n"
- " x264,x264b13, default: ffmpeg)\n"
+ " x264,x264b13,x264b30 default: ffmpeg)\n"
" -E, --aencoder <string> Set audio encoder (faac/lame/vorbis/ac3, ac3\n"
" meaning passthrough, default: guessed)\n"
" -2, --two-pass Use two-pass mode\n"
vcodec = HB_VCODEC_X264;
h264_13 = 1;
}
+ else if( !strcasecmp( optarg, "x264b30" ) )
+ {
+ vcodec = HB_VCODEC_X264;
+ h264_30 = 1;
+ }
else
{
fprintf( stderr, "invalid codec (%s)\n", optarg );
}
else if( p && !strcasecmp( p, ".mp4" ) )
{
- mux = HB_MUX_MP4;
+ if ( h264_30 == 1 )
+ mux = HB_MUX_IPOD;
+ else
+ mux = HB_MUX_MP4;
}
else if( p && ( !strcasecmp( p, ".ogm" ) ||
!strcasecmp( p, ".ogg" ) ) )
}
else if( !strcasecmp( format, "mp4" ) )
{
- mux = HB_MUX_MP4;
+ if ( h264_30 == 1)
+ mux = HB_MUX_IPOD;
+ else
+ mux = HB_MUX_MP4;
}
else if( !strcasecmp( format, "ogm" ) ||
!strcasecmp( format, "ogg" ) )
if( !acodec )
{
- if( mux == HB_MUX_MP4 )
+ if( mux == HB_MUX_MP4 || mux == HB_MUX_IPOD )
{
acodec = HB_ACODEC_FAAC;
}