diff options
author | rhester <[email protected]> | 2006-09-30 16:21:26 +0000 |
---|---|---|
committer | rhester <[email protected]> | 2006-09-30 16:21:26 +0000 |
commit | 1806e33ca8df880e33657d3a30e537ae620fadef (patch) | |
tree | 69482a657f855d09d669e94ec0bd3251d6092406 /libhb | |
parent | 5f8684be8ecc912a8828ae3c21857125255a590b (diff) |
HandBrake 0.7.1a1
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://svn.handbrake.fr/HandBrake/trunk@70 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.c | 1 | ||||
-rw-r--r-- | libhb/common.h | 4 | ||||
-rw-r--r-- | libhb/dvd.c | 2 | ||||
-rw-r--r-- | libhb/encx264.c | 89 | ||||
-rw-r--r-- | libhb/muxcommon.c | 1 | ||||
-rw-r--r-- | libhb/muxmp4.c | 78 | ||||
-rw-r--r-- | libhb/muxogm.c | 2 | ||||
-rw-r--r-- | libhb/scan.c | 2 |
8 files changed, 105 insertions, 74 deletions
diff --git a/libhb/common.c b/libhb/common.c index 105fa44f5..e9d366f75 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -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: diff --git a/libhb/common.h b/libhb/common.h index 866eb98b2..0bd8971e3 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -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; diff --git a/libhb/dvd.c b/libhb/dvd.c index faa82b2e0..4082a18d3 100644 --- a/libhb/dvd.c +++ b/libhb/dvd.c @@ -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 ); diff --git a/libhb/encx264.c b/libhb/encx264.c index 13faadc39..53950fa5e 100644 --- a/libhb/encx264.c +++ b/libhb/encx264.c @@ -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( ¶m ); - + 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( ¶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; @@ -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; } diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c index 8deba08e3..93fa773e3 100644 --- a/libhb/muxcommon.c +++ b/libhb/muxcommon.c @@ -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: diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c index 21aea7a53..971c4bfbb 100644 --- a/libhb/muxmp4.c +++ b/libhb/muxmp4.c @@ -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( ¶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; } @@ -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; } diff --git a/libhb/muxogm.c b/libhb/muxogm.c index d326c9828..6a3b1ec5d 100644 --- a/libhb/muxogm.c +++ b/libhb/muxogm.c @@ -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; diff --git a/libhb/scan.c b/libhb/scan.c index c2814f362..097f11638 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -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 ) ) { |