It may be used under the terms of the GNU General Public License v2.
For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
*/
-
+
#include "hb.h"
#include "hbffmpeg.h"
#include <stdio.h>
struct hb_handle_s
{
int id;
-
+
/* The "Check for update" thread */
int build;
char version[32];
increments each time the scan thread completes*/
int scanCount;
volatile int scan_die;
-
+
/* Stash of persistent data between jobs, for stuff
like correcting frame count and framerate estimates
on multi-pass encodes where frames get dropped. */
{
int ret;
- if ((thread_count == HB_FFMPEG_THREADS_AUTO || thread_count > 0) &&
+ if ((thread_count == HB_FFMPEG_THREADS_AUTO || thread_count > 0) &&
(codec->type == AVMEDIA_TYPE_VIDEO))
{
avctx->thread_count = (thread_count == HB_FFMPEG_THREADS_AUTO) ?
av_opt_set_int(ctx, "dst_format", dstFormat, 0);
av_opt_set_int(ctx, "sws_flags", flags, 0);
- sws_setColorspaceDetails( ctx,
+ sws_setColorspaceDetails( ctx,
sws_getCoefficients( SWS_CS_DEFAULT ), // src colorspace
srcRange, // src range 0 = MPG, 1 = JPG
sws_getCoefficients( SWS_CS_DEFAULT ), // dst colorspace
fprintf(stderr, "Cannot initialize resampling context\n");
sws_freeContext(ctx);
ctx = NULL;
- }
+ }
}
return ctx;
}
#ifdef USE_QSV
// make the Intel QSV information available to the UIs
hb_qsv_info_t *hb_qsv_info = NULL;
-#endif
// minimum supported version (currently 1.4, for Sandy Bridge support)
// let's keep this independent of what Libav can do for decode
global_verbosity_level = verbose;
if( verbose )
putenv( "HB_DEBUG=1" );
-
+
h->id = hb_instance_counter++;
-
+
/* Check for an update on the website if asked to */
h->build = -1;
h->die = 0;
h->main_thread = hb_thread_init( "libhb", thread_func, h,
HB_NORMAL_PRIORITY );
-
+
return h;
}
h->main_thread = hb_thread_init( "libhb", thread_func, h,
HB_NORMAL_PRIORITY );
- return h;
+ return h;
}
}
hb_log( "hb_scan: path=%s, title_index=%d", path, title_index );
- h->scan_thread = hb_scan_init( h, &h->scan_die, path, title_index,
- &h->title_set, preview_count,
+ h->scan_thread = hb_scan_init( h, &h->scan_die, path, title_index,
+ &h->title_set, preview_count,
store_previews, min_duration );
}
int hb_detect_comb( hb_buffer_t * buf, int color_equal, int color_diff, int threshold, int prog_equal, int prog_diff, int prog_threshold )
{
int j, k, n, off, cc_1, cc_2, cc[3];
- // int flag[3] ; // debugging flag
+ // int flag[3] ; // debugging flag
uint16_t s1, s2, s3, s4;
cc_1 = 0; cc_2 = 0;
threshold = prog_threshold;
}
- /* One pas for Y, one pass for Cb, one pass for Cr */
+ /* One pas for Y, one pass for Cb, one pass for Cr */
for( k = 0; k < 3; k++ )
{
uint8_t * data = buf->plane[k].data;
/* HandBrake is all yuv420, so weight the average percentage of all 3 planes accordingly.*/
int average_cc = ( 2 * cc[0] + ( cc[1] / 2 ) + ( cc[2] / 2 ) ) / 3;
-
+
/* Now see if that average percentage of combed pixels surpasses the threshold percentage given by the user.*/
if( average_cc > threshold )
{
double storage_aspect = (double)cropped_width / (double)cropped_height;
int mod = job->modulus ? job->modulus : 16;
double aspect = title->aspect;
-
+
int64_t pixel_aspect_width = job->anamorphic.par_width;
int64_t pixel_aspect_height = job->anamorphic.par_height;
*output_height = MULTIPLE_MOD( cropped_height, 2 );
// adjust the source PAR for new width/height
// new PAR = source PAR * ( old width / new_width ) * ( new_height / old_height )
- pixel_aspect_width = (int64_t)title->pixel_aspect_width * cropped_width * (*output_height);
+ pixel_aspect_width = (int64_t)title->pixel_aspect_width * cropped_width * (*output_height);
pixel_aspect_height = (int64_t)title->pixel_aspect_height * (*output_width) * cropped_height;
break;
/* Time to get picture height that divide cleanly.*/
height = MULTIPLE_MOD( height, mod);
-
+
if ( maxHeight && (maxHeight < height) )
{
height = maxHeight;
*output_width = width;
*output_height = height;
break;
-
+
case 3:
/* Anamorphic 3: Power User Jamboree
- Set everything based on specified values */
-
+
/* Use specified storage dimensions */
storage_aspect = (double)job->width / (double)job->height;
width = job->width;
height = job->height;
-
+
/* Time to get picture dimensions that divide cleanly.*/
width = MULTIPLE_MOD( width, mod);
height = MULTIPLE_MOD( height, mod);
-
+
/* Bind to max dimensions */
if( maxWidth && width > maxWidth )
{
width = MULTIPLE_MOD( width, mod);
}
}
-
- /* That finishes the storage dimensions. On to display. */
+
+ /* That finishes the storage dimensions. On to display. */
if( job->anamorphic.dar_width && job->anamorphic.dar_height )
{
/* We need to adjust the PAR to produce this aspect. */
pixel_aspect_height = width;
}
}
-
+
/* Back to caller */
*output_width = width;
*output_height = height;
break;
}
-
+
/* While x264 is smart enough to reduce fractions on its own, libavcodec
* needs some help with the math, so lose superfluous factors. */
hb_limit_rational64( &pixel_aspect_width, &pixel_aspect_height,
* language.
*/
job_copy->list_subtitle = hb_list_init();
-
+
for( i = 0; i < hb_list_count( job->title->list_subtitle ); i++ )
{
subtitle = hb_list_item( job->title->list_subtitle, i );
hb_title_t * title;
h->die = 1;
-
+
hb_thread_close( &h->main_thread );
while( ( title = hb_list_item( h->title_set.list_title, 0 ) ) )
hb_register(&hb_reader);
hb_register(&hb_sync_video);
hb_register(&hb_sync_audio);
-ifdef USE_QSV
+#ifdef USE_QSV
hb_register(&hb_encqsv);
#endif
hb_register(&hb_deca52);
hb_register(&hb_enctheora);
hb_register(&hb_encvorbis);
hb_register(&hb_encx264);
-
+
hb_common_global_init();
#ifdef USE_QSV
char dirname[1024];
DIR * dir;
struct dirent * entry;
-
+
/* Find and remove temp folder */
memset( dirname, 0, 1024 );
hb_get_temporary_directory( dirname );
}
hb_lock( h->state_lock );
h->state.state = HB_STATE_SCANDONE; //originally state.state
- hb_unlock( h->state_lock );
- /*we increment this sessions scan count by one for the MacGui
- to trigger a new source being set */
+ hb_unlock( h->state_lock );
+ /*we increment this sessions scan count by one for the MacGui
+ to trigger a new source being set */
h->scanCount++;
}
dup2(pfd[1], /*stderr*/ 2);
#endif
FILE * log_f = fdopen(pfd[0], "rb");
-
+
char line_buffer[500];
while(fgets(line_buffer, 500, log_f) != NULL)
{