OSDN Git Service

HandBrake 0.7.1a1
authorrhester <rhester@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 30 Sep 2006 16:21:26 +0000 (16:21 +0000)
committerrhester <rhester@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 30 Sep 2006 16:21:26 +0000 (16:21 +0000)
Made H.264 baseline levels more generic
Added iPod 640x480 support to libhb, HBTest and MacOS X GUI
Added proper iPod 640x480 muxing
Modified rate control for more accurate ending video bitrates
Updated ffmpeg and x264 base sources to more current levels
Removed inlined ff_get_fourcc (now in ffmpeg)
Updated patches for xvidcore, libdvdread, x264, and ffmpeg
Relocated contrib files to local web server and updated version files to new site
Renamed contrib files and patches to consistent naming standard
Updated contrib Jamfile to support new patches and naming standard

git-svn-id: svn://localhost/HandBrake/trunk@70 b64f7644-9d1e-0410-96f1-a4d463321fa5

28 files changed:
Jamrules
contrib/Jamfile
contrib/patch-ffmpeg.patch
contrib/patch-libdvdread.patch [new file with mode: 0644]
contrib/patch-x264-macintel.patch [new file with mode: 0644]
contrib/patch-xvidcore.patch [moved from contrib/xvidcore.patch with 100% similarity]
contrib/version_a52dec.txt
contrib/version_faac.txt
contrib/version_ffmpeg.txt
contrib/version_lame.txt
contrib/version_libdvdcss.txt
contrib/version_libdvdread.txt
contrib/version_libogg.txt
contrib/version_libsamplerate.txt
contrib/version_libvorbis.txt
contrib/version_mpeg2dec.txt
contrib/version_x264.txt
contrib/version_xvidcore.txt
libhb/common.c
libhb/common.h
libhb/dvd.c
libhb/encx264.c
libhb/muxcommon.c
libhb/muxmp4.c
libhb/muxogm.c
libhb/scan.c
macosx/Controller.mm
test/test.c

index c44b6ca..7fff888 100644 (file)
--- a/Jamrules
+++ b/Jamrules
@@ -11,8 +11,8 @@ if ! $(DEFINES)
     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 ;
index 0add85e..92666a9 100644 (file)
@@ -54,8 +54,8 @@ rule LibAvCodec
 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
@@ -95,6 +95,7 @@ LibDvdCss $(SUBDIR)/lib/libdvdcss.a  : $(SUBDIR)/libdvdcss.tar.gz ;
 # libdvdread
 rule LibDvdRead
 {
+    LIBDVDREAD_PATCH = "patch -p1 < ../patch-libdvdread.patch" ;
     Depends $(<) : $(>) ;
     Depends lib  : $(<) ;
 }
@@ -102,6 +103,7 @@ actions LibDvdRead
 {
     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
@@ -225,13 +227,18 @@ LibVorbisEnc $(SUBDIR)/lib/libvorbisenc.a : $(SUBDIR)/lib/libvorbis.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
@@ -249,7 +256,7 @@ actions LibXvidCore
 {
     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/ &&
index c653641..c9cc5fa 100644 (file)
-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;
          }
@@ -94,3 +139,35 @@ diff -ru ffmpeg-20060326-bak/libavformat/tcp.c ffmpeg-20060326/libavformat/tcp.c
      }
      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
diff --git a/contrib/patch-libdvdread.patch b/contrib/patch-libdvdread.patch
new file mode 100644 (file)
index 0000000..8ff5333
--- /dev/null
@@ -0,0 +1,10 @@
+--- 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);
+ }
diff --git a/contrib/patch-x264-macintel.patch b/contrib/patch-x264-macintel.patch
new file mode 100644 (file)
index 0000000..b2219fd
--- /dev/null
@@ -0,0 +1,48 @@
+--- 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
+ ;-----------------------------------------------------------------------------
index 86617fd..784ed9f 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/a52dec-0.7.4.tar.gz
+http://multics.dynalias.com/handbrake/contrib/a52dec-0.7.4.tar.gz
index e346666..c79fdb9 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/faac-1.24.tar.gz
+http://multics.dynalias.com/handbrake/contrib/faac-1.24.tar.gz
index a13a338..e784fb8 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/ffmpeg-20060326.tar.gz
+http://multics.dynalias.com/handbrake/contrib/ffmpeg-6324.tar.gz
index b4bb63c..fcee5aa 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/lame-3.96.1.tar.gz
+http://multics.dynalias.com/handbrake/contrib/lame-3.96.1.tar.gz
index 81d1ef1..f4ee8b1 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/libdvdcss-1.2.9.tar.gz
+http://multics.dynalias.com/handbrake/contrib/libdvdcss-1.2.9.tar.gz
index b7be38f..63b29a4 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/libdvdread-20050928.tar.gz
+http://multics.dynalias.com/handbrake/contrib/libdvdread-20050928.tar.gz
index 57daaf7..48cb46d 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/libogg-1.1.2.tar.gz
+http://multics.dynalias.com/handbrake/contrib/libogg-1.1.2.tar.gz
index a0f5b38..c7d75ca 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/libsamplerate-0.1.2.tar.gz
+http://multics.dynalias.com/handbrake/contrib/libsamplerate-0.1.2.tar.gz
index db3f67c..18c9a7a 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/libvorbis-1.1.1.tar.gz
+http://multics.dynalias.com/handbrake/contrib/libvorbis-1.1.1.tar.gz
index a1e4730..f857001 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/mpeg2dec-20051112.tar.gz
+http://multics.dynalias.com/handbrake/contrib/mpeg2dec-20051112.tar.gz
index dbf8c57..9d6f628 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/x264-r401.tar.gz
+http://multics.dynalias.com/handbrake/contrib/x264-r568.tar.gz
index 28a7cff..c5b9515 100644 (file)
@@ -1 +1 @@
-http://download.m0k.org/handbrake/contrib/xvidcore-1.1.0.tar.gz
+http://multics.dynalias.com/handbrake/contrib/xvidcore-1.1.0.tar.gz
index 105fa44..e9d366f 100644 (file)
@@ -116,6 +116,7 @@ int hb_calc_bitrate( hb_job_t * job, int size )
     {
        case HB_MUX_MP4:
        case HB_MUX_PSP:
+               case HB_MUX_IPOD:
             overhead = 6;
             break; 
         case HB_MUX_AVI:
index 866eb98..0bd8971 100644 (file)
@@ -115,6 +115,7 @@ struct hb_job_s
 #define HB_VCODEC_FFMPEG 0x000001
 #define HB_VCODEC_XVID   0x000002
 #define HB_VCODEC_X264   0x000004
+
     int             vcodec;
     float           vquality;
     int             vbitrate;
@@ -122,6 +123,7 @@ struct hb_job_s
     int             vrate_base;
     int             pass;
     int             h264_13;
+       int                             h264_level;
 
     /* Audio tracks:
          Indexes in hb_title_t's audios list, starting from 0.
@@ -158,6 +160,8 @@ struct hb_job_s
 #define HB_MUX_PSP  0x020000
 #define HB_MUX_AVI  0x040000
 #define HB_MUX_OGM  0x080000
+#define HB_MUX_IPOD 0x100000
+       
     int             mux;
     char          * file;
 
index faa82b2..4082a18 100644 (file)
@@ -183,7 +183,7 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
             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 );
index 13faadc..53950fa 100644 (file)
@@ -1,8 +1,8 @@
 /* $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>
 
@@ -29,32 +29,32 @@ struct hb_work_private_s
     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( &param );
-
+       
     param.i_threads    = hb_get_cpu_count();
     param.i_width      = job->width;
     param.i_height     = job->height;
@@ -62,16 +62,19 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
     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 */
@@ -81,29 +84,40 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
     }
     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( &param );
-
+       
     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;
@@ -111,10 +125,10 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
                          &size, 1, &nal[i] );
         w->config->mpeg4.length += size;
     }
-
+       
     x264_picture_alloc( &pv->pic_in, X264_CSP_I420,
                         job->width, job->height );
-
+       
     return 0;
 }
 
@@ -122,12 +136,12 @@ void encx264Close( hb_work_object_t * w )
 {
     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;
@@ -135,7 +149,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
     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 )
@@ -151,19 +165,22 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
         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++ )
     {
@@ -175,9 +192,9 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
             buf->size += size;
         }
     }
-
+       
     *buf_out = buf;
-
+       
     return HB_WORK_OK;
 }
 
index 8deba08..93fa773 100644 (file)
@@ -71,6 +71,7 @@ static void MuxerFunc( void * _mux )
         {
             case HB_MUX_MP4:
             case HB_MUX_PSP:
+                       case HB_MUX_IPOD:
                 m = hb_mux_mp4_init( job );
                 break;
             case HB_MUX_AVI:
index 21aea7a..971c4bf 100644 (file)
@@ -1,25 +1,21 @@
 /* $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;
 };
 
@@ -29,10 +25,10 @@ struct hb_mux_data_s
 };
 
 /**********************************************************************
- * 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;
@@ -43,28 +39,40 @@ static int MP4Init( hb_mux_object_t * m )
     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 )
     {
@@ -75,28 +83,28 @@ static int MP4Init( hb_mux_object_t * m )
     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 )
         {
@@ -116,35 +124,35 @@ static int MP4Init( hb_mux_object_t * m )
         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( &params, 0, sizeof( params ) );
     if( av_set_parameters( oc, &params ) < 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;
 }
 
@@ -153,19 +161,19 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
 {
     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;
 }
 
@@ -174,7 +182,7 @@ static int MP4End( hb_mux_object_t * m )
     av_write_trailer( m->format );
     url_fclose( &m->format->pb );
     av_free( m->format );
-
+       
     return 0;
 }
 
index d326c98..6a3b1ec 100644 (file)
@@ -170,7 +170,7 @@ static int OGMInit( hb_mux_object_t * m )
     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;
index c2814f3..097f116 100644 (file)
@@ -248,7 +248,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
 
         mpeg2 = hb_libmpeg2_init();
 
-        for( j = 0; j < 10240; j++ )
+        for( j = 0; j < 10240 ; j++ )
         {
             if( !hb_dvd_read( data->dvd, buf_ps ) )
             {
index a71f121..10b1231 100644 (file)
@@ -556,6 +556,19 @@ static int FormatSettings[3][4] =
     }
     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];
     }
 
@@ -881,7 +894,8 @@ static int FormatSettings[3][4] =
         /* 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 ) )
     {
index e01bec7..0f43a7f 100644 (file)
@@ -21,6 +21,7 @@ static int    deinterlace = 0;
 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;
@@ -341,8 +342,12 @@ static int HandleEvents( hb_handle_t * h )
             }
             if( h264_13 ) 
             { 
-                job->h264_13 = h264_13; 
-            } 
+                job->h264_level = 13; 
+            }
+           if( h264_30 )
+           {
+               job->h264_level = 30;
+            }
             if( vrate )
             {
                 job->vrate = 27000000;
@@ -505,7 +510,7 @@ static void ShowHelp()
     "\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"
@@ -673,6 +678,11 @@ static int ParseOptions( int argc, char ** argv )
                     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 );
@@ -801,7 +811,10 @@ static int CheckOptions( int argc, char ** argv )
             }
             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" ) ) )
@@ -821,7 +834,10 @@ static int CheckOptions( int argc, char ** argv )
         }
         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" ) )
@@ -837,7 +853,7 @@ static int CheckOptions( int argc, char ** argv )
 
         if( !acodec )
         {
-            if( mux == HB_MUX_MP4 )
+            if( mux == HB_MUX_MP4 || mux == HB_MUX_IPOD )
             {
                 acodec = HB_ACODEC_FAAC;
             }