| 90 | } |
| 91 | |
| 92 | static int hb_reader_open( hb_work_private_t * r ) |
| 93 | { |
| 94 | if ( r->title->type == HB_BD_TYPE ) |
| 95 | { |
| 96 | if ( !( r->bd = hb_bd_init( r->h, r->title->path, r->job->keep_duplicate_titles ) ) ) |
| 97 | return 1; |
| 98 | if(!hb_bd_start(r->bd, r->title)) |
| 99 | { |
| 100 | hb_bd_close(&r->bd); |
| 101 | return 1; |
| 102 | } |
| 103 | if (r->job->angle > 1) |
| 104 | { |
| 105 | hb_bd_set_angle(r->bd, r->job->angle - 1); |
| 106 | } |
| 107 | if (r->job->start_at_preview) |
| 108 | { |
| 109 | // XXX code from DecodePreviews - should go into its own routine |
| 110 | hb_bd_seek(r->bd, (float)r->job->start_at_preview / |
| 111 | (r->job->seek_points ? (r->job->seek_points + 1.0) |
| 112 | : 11.0)); |
| 113 | } |
| 114 | else if (r->job->pts_to_start) |
| 115 | { |
| 116 | // Note, bd seeks always put us to an i-frame. no need |
| 117 | // to start decoding early using r->pts_to_start |
| 118 | hb_bd_seek_pts(r->bd, r->job->pts_to_start); |
| 119 | r->duration -= r->job->pts_to_start; |
| 120 | r->job->reader_pts_offset = r->job->pts_to_start; |
| 121 | r->start_found = 1; |
| 122 | } |
| 123 | else |
| 124 | { |
| 125 | hb_bd_seek_chapter(r->bd, r->job->chapter_start); |
| 126 | r->duration -= chapter_end_pts(r->job->title, |
| 127 | r->job->chapter_start - 1); |
| 128 | } |
| 129 | } |
| 130 | else if (r->title->type == HB_DVD_TYPE) |
| 131 | { |
| 132 | if ( !( r->dvd = hb_dvd_init( r->h, r->title->path ) ) ) |
| 133 | return 1; |
| 134 | if(!hb_dvd_start( r->dvd, r->title, r->job->chapter_start)) |
| 135 | { |
| 136 | hb_dvd_close(&r->dvd); |
| 137 | return 1; |
| 138 | } |
| 139 | r->duration -= chapter_end_pts(r->job->title, |
| 140 | r->job->chapter_start - 1); |
| 141 | if (r->job->angle) |
| 142 | { |
| 143 | hb_dvd_set_angle(r->dvd, r->job->angle); |
| 144 | } |
| 145 | |
| 146 | if (r->job->start_at_preview) |
| 147 | { |
| 148 | hb_dvd_seek(r->dvd, (float)r->job->start_at_preview / |
| 149 | (r->job->seek_points ? (r->job->seek_points + 1.0) |
no test coverage detected