int64_t pts_to_stop; // declare eof when we pass this pts in
// the time-linearized input stream
int start_at_preview; // if non-zero, encoding will start
- // at the position of preview n (1-10)
+ // at the position of preview n
+ int seek_points; // out of N previews
uint32_t frames_to_skip; // decode but discard this many frames
// initially (for frame accurate positioning
// to non-I frames).
* @param h Handle to hb_handle_t
* @param path location of VIDEO_TS folder.
* @param title_index Desired title to scan. 0 for all titles.
+ * @param preview_count Number of preview images to generate.
+ * @param store_previews Whether or not to write previews to disk.
*/
-void hb_scan( hb_handle_t * h, const char * path, int title_index )
+void hb_scan( hb_handle_t * h, const char * path, int title_index,
+ int preview_count, int store_previews )
{
hb_title_t * title;
}
hb_log( "hb_scan: path=%s, title_index=%d", path, title_index );
- h->scan_thread = hb_scan_init( h, path, title_index, h->list_title );
+ h->scan_thread = hb_scan_init( h, path, title_index, h->list_title,
+ preview_count, store_previews );
}
/**
Scan the specified path. Can be a DVD device, a VIDEO_TS folder or
a VOB file. If title_index is 0, scan all titles. */
void hb_scan( hb_handle_t *, const char * path,
- int title_index );
+ int title_index, int preview_count,
+ int store_previews );
/* hb_get_titles()
Returns the list of valid titles detected by the latest scan. */
**********************************************************************/
hb_thread_t * hb_update_init( int * build, char * version );
hb_thread_t * hb_scan_init( hb_handle_t *, const char * path,
- int title_index, hb_list_t * list_title );
+ int title_index, hb_list_t * list_title,
+ int preview_count, int store_previews );
hb_thread_t * hb_work_init( hb_list_t * jobs, int cpu_count,
volatile int * die, int * error, hb_job_t ** job );
hb_thread_t * hb_reader_init( hb_job_t * );
if ( r->job->start_at_preview )
{
// XXX code from DecodePreviews - should go into its own routine
- hb_dvd_seek( r->dvd, (float)r->job->start_at_preview / 11. );
+ hb_dvd_seek( r->dvd, (float)r->job->start_at_preview /
+ ( r->job->seek_points ? ( r->job->seek_points + 1.0 ) : 11.0 ) );
}
}
else if ( r->stream && r->job->start_at_preview )
{
// XXX code from DecodePreviews - should go into its own routine
- hb_stream_seek( r->stream, (float)( r->job->start_at_preview - 1 ) / 11. );
+ hb_stream_seek( r->stream, (float)( r->job->start_at_preview - 1 ) /
+ ( r->job->seek_points ? ( r->job->seek_points + 1.0 ) : 11.0 ) );
+
}
list = hb_list_init();
#include "a52dec/a52.h"
#include "dca.h"
+#define HB_MAX_PREVIEWS 30 // 30 previews = every 5 minutes of a 2.5 hour video
+
typedef struct
{
hb_handle_t * h;
hb_dvd_t * dvd;
hb_stream_t * stream;
+
+ int preview_count;
+ int store_previews;
} hb_scan_t;
}
hb_thread_t * hb_scan_init( hb_handle_t * handle, const char * path,
- int title_index, hb_list_t * list_title )
+ int title_index, hb_list_t * list_title,
+ int preview_count, int store_previews )
{
hb_scan_t * data = calloc( sizeof( hb_scan_t ), 1 );
data->path = strdup( path );
data->title_index = title_index;
data->list_title = list_title;
-
+
+ data->preview_count = preview_count;
+ data->store_previews = store_previews;
+
return hb_thread_init( "scan", ScanFunc, data, HB_NORMAL_PRIORITY );
}
typedef struct {
int n;
- int t[10];
- int b[10];
- int l[10];
- int r[10];
+ int t[HB_MAX_PREVIEWS];
+ int b[HB_MAX_PREVIEWS];
+ int l[HB_MAX_PREVIEWS];
+ int r[HB_MAX_PREVIEWS];
} crop_record_t;
static void record_crop( crop_record_t *crops, int t, int b, int l, int r )
hb_list_t * list_es;
int progressive_count = 0;
int interlaced_preview_count = 0;
- info_list_t * info_list = calloc( 10+1, sizeof(*info_list) );
+ info_list_t * info_list = calloc( data->preview_count+1, sizeof(*info_list) );
crop_record_t *crops = calloc( 1, sizeof(*crops) );
buf_ps = hb_buffer_init( HB_DVD_READ_BUFFER_SIZE );
if (data->dvd)
hb_dvd_start( data->dvd, title->index, 1 );
- for( i = 0; i < 10; i++ )
+ for( i = 0; i < data->preview_count; i++ )
{
int j;
FILE * file_preview;
if (data->dvd)
{
- if( !hb_dvd_seek( data->dvd, (float) ( i + 1 ) / 11.0 ) )
+ if( !hb_dvd_seek( data->dvd, (float) ( i + 1 ) / ( data->preview_count + 1.0 ) ) )
{
continue;
}
/* we start reading streams at zero rather than 1/11 because
* short streams may have only one sequence header in the entire
* file and we need it to decode any previews. */
- if (!hb_stream_seek(data->stream, (float) i / 11.0 ) )
+ if (!hb_stream_seek(data->stream, (float) i / ( data->preview_count + 1.0 ) ) )
{
continue;
}
hb_deep_log( 2, "Interlacing detected in preview frame %i", i+1);
interlaced_preview_count++;
}
-
- hb_get_tempory_filename( data->h, filename, "%x%d",
- (intptr_t)title, i );
-
- file_preview = fopen( filename, "w" );
- if( file_preview )
- {
- fwrite( vid_buf->data, title->width * title->height * 3 / 2,
- 1, file_preview );
- fclose( file_preview );
- }
- else
+
+ if( data->store_previews )
{
- hb_log( "scan: fopen failed (%s)", filename );
+ hb_get_tempory_filename( data->h, filename, "%x%d",
+ (intptr_t)title, i );
+
+ file_preview = fopen( filename, "w" );
+ if( file_preview )
+ {
+ fwrite( vid_buf->data, title->width * title->height * 3 / 2,
+ 1, file_preview );
+ fclose( file_preview );
+ }
+ else
+ {
+ hb_log( "scan: fopen failed (%s)", filename );
+ }
}
/* Detect black borders */
static int mp4_optimize = 0;
static int ipod_atom = 0;
static int color_matrix = 0;
+static int preview_count = 10;
+static int store_previews = 0;
/* Exit cleanly on Ctrl-C */
static volatile int die = 0;
*/
titleindex = 0;
}
- hb_scan( h, input, titleindex );
+
+ hb_scan( h, input, titleindex, preview_count, store_previews );
/* Wait... */
while( !die )
" -c, --chapters <string> Select chapters (e.g. \"1-3\" for chapters\n"
" 1 to 3, or \"3\" for chapter 3 only,\n"
" default: all chapters)\n"
+ " --previews <#:B> Select how many preview images are generated (max 30),\n"
+ " and whether or not they're stored to disk (0 or 1).\n"
+ " (default: 10:0)\n"
"\n"
"### Destination Options------------------------------------------------------\n\n"
****************************************************************************/
static int ParseOptions( int argc, char ** argv )
{
+
+ #define PREVIEWS 257
+
for( ;; )
{
static struct option long_options[] =
{ "aname", required_argument, NULL, 'A' },
{ "color-matrix",required_argument, NULL, 'M' },
+ { "previews", required_argument, NULL, PREVIEWS },
{ 0, 0, 0, 0 }
};
anames = strdup( optarg );
}
break;
+ case PREVIEWS:
+ sscanf( optarg, "%i:%i", &preview_count, &store_previews );
+ break;
case 'M':
if( atoi( optarg ) == 601 )
color_matrix = 1;