Changeset 3689
- Timestamp:
- 12/17/06 03:20:12 (2 years ago)
- Files:
-
- ivtvtv/trunk/ivtvtv.cpp (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ivtvtv/trunk/ivtvtv.cpp
r3687 r3689 12 12 13 13 #include <string> 14 15 int g_skip = 0; 16 int g_spd = 0; 17 int idx = 0; 14 18 15 19 #if 0 … … 55 59 static int ivtv_api_dec_speed(int ivtvfd, int direction, int speed) 56 60 { 57 int b_per_gop = 1;61 int b_per_gop = 2; 58 62 int aud_mute = 0; 59 63 int fr_field = 0; … … 63 67 int ip_frames = 1; 64 68 int ipb_frames = 2; 69 70 if (speed > 2) 71 speed = 2; 65 72 66 73 /* Make input sane */ … … 73 80 if (speed < 0) { 74 81 __ivtv_api_dec_speed(ivtvfd, 75 -speed , 0, 0, direction,82 -speed+1, 0, 0, direction, 76 83 ipb_frames, 0, aud_mute, fr_field, mute); 77 84 } else if (speed == 0) { … … 79 86 0, 0, 0, direction, ipb_frames, 0, 80 87 aud_mute, fr_field, mute); 81 } else if (speed == 1 || speed == 2) {82 __ivtv_api_dec_speed(ivtvfd, 83 speed, 0, 1, direction,88 } else if (speed == 1) { 89 __ivtv_api_dec_speed(ivtvfd, 90 speed, 1, 1, direction, 84 91 ipb_frames, 0, aud_mute, fr_field, mute); 85 92 } else { 86 93 __ivtv_api_dec_speed(ivtvfd, 87 0, 0, 0, direction, i_frames, 0,94 speed, 0, 1, direction, i_frames, 0, 88 95 aud_mute, fr_field, mute); 89 96 } … … 91 98 if (speed < 0) { 92 99 __ivtv_api_dec_speed(ivtvfd, 93 -speed , 0, 0, direction, ip_frames,100 -speed+1, 0, 0, direction, ip_frames, 94 101 b_per_gop, aud_mute, fr_field, mute); 95 102 } else if (speed == 0) { … … 101 108 speed, 0, 1, direction, ip_frames, 102 109 b_per_gop, aud_mute, fr_field, mute); 103 } else if (speed > 2){104 __ivtv_api_dec_speed(ivtvfd, 105 0, 0, 0, direction, i_frames,110 } else { 111 __ivtv_api_dec_speed(ivtvfd, 112 speed, 0, 1, direction, i_frames, 106 113 b_per_gop, aud_mute, fr_field, mute); 107 } else {108 __ivtv_api_dec_speed(ivtvfd,109 speed, 0, 1, direction,110 ipb_frames, b_per_gop, aud_mute,111 fr_field, mute);112 114 } 113 115 } … … 119 121 void speed(int fh, int delta) 120 122 { 121 static int spd = 0; 122 123 spd += delta; 124 printf("dir = %d spd = %d\n", dir, spd); 125 ivtv_api_dec_speed(fh, dir, spd); 123 g_spd += delta; 124 printf("dir = %d spd = %d\n", dir, g_spd); 125 ivtv_api_dec_speed(fh, dir, g_spd); 126 126 } 127 127 128 128 void process(int fh, int ch) 129 129 { 130 struct ivtv_cfg_start_decode start; 131 struct ivtv_cfg_stop_decode stop; 130 132 int step = 0; 131 133 … … 141 143 break; 142 144 case 'r': 145 dir = 0; 146 speed(fh, 0); 143 147 ioctl(fh, IVTV_IOC_PLAY, 0); 148 break; 149 case 'd': 150 dir = !dir; 151 stop.hide_last = 0; 152 stop.pts_stop = 0; 153 ioctl(fh, IVTV_IOC_STOP_DECODE, &stop); 154 start.gop_offset = 0; 155 start.muted_audio_frames = 0; 156 ioctl(fh, IVTV_IOC_START_DECODE, &start); 157 speed(fh, 0); 158 if (dir) idx -= g_skip; 159 else idx += g_skip; 160 if (idx < 0) idx = 0; 144 161 break; 145 162 case '-': … … 176 193 unsigned long long *indices; 177 194 int max_idx; 178 int idx = 0;179 195 180 196 if (argc < 3) { … … 208 224 max_sz = indices[i+1] - indices[i]; 209 225 buf = new char[max_sz]; 226 printf("max %d\n", max_sz); 210 227 211 228 //if (fin > fmax) fmax = fin; … … 215 232 exit(1); 216 233 } 234 int fast = 1; 235 ioctl(fout, IVTV_IOC_DEC_FAST_STOP, &fast); 236 //ioctl(fout, IVTV_IOC_DEC_SPLICE, &fast); 217 237 if (fout > fmax) fmax = fout; 218 238 219 239 fd_set fd_in; 220 240 fd_set fd_out; 241 int first = 1; 242 time_t t1, t2; 243 int cnt = 0; 244 245 t1 = time(NULL); 221 246 222 247 while (1) { … … 241 266 if (bufoffset == bufsz) { 242 267 ssize_t sz; 268 int i = idx; 243 269 244 270 if (dir) { … … 247 273 break; 248 274 } 249 idx --;275 idx -= g_spd > 2 ? g_spd-1 : 1; 250 276 } 251 277 else { … … 254 280 break; 255 281 } 256 idx ++;257 } 258 lseek(fin, indices[i dx], SEEK_SET);259 bufsz = indices[i dx + 1] - indices[idx];282 idx += g_spd > 2 ? g_spd-1 : 1; 283 } 284 lseek(fin, indices[i], SEEK_SET); 285 bufsz = indices[i + 1] - indices[i]; 260 286 sz = read(fin, buf, bufsz); 287 struct ivtv_ioctl_framesync info; 288 ioctl(fout, IVTV_IOC_GET_TIMING, &info); 289 printf("frame %d %lld %d\n", info.frame, info.pts, idx); 290 cnt++; 291 t2 = time(NULL); 292 if (t1 != t2) { 293 // printf("sec %d %d\n", cnt, t2 - t1); 294 cnt = 0; 295 t1 = t2; 296 } 297 if (info.frame && first) { 298 first = 0; 299 g_skip = idx; 300 printf("skip = %d\n", g_skip); 301 } 261 302 262 303 if (sz == 0) { … … 277 318 } 278 319 } 320 fast = 0; 321 ioctl(fout, IVTV_IOC_DEC_FAST_STOP, &fast); 322 struct ivtv_cfg_stop_decode stop; 323 stop.hide_last = 1; 324 stop.pts_stop = 0; 325 //ioctl(fout, IVTV_IOC_STOP_DECODE, &stop); 326 ioctl(fout, VIDIOC_STREAMOFF, 0); 279 327 return 0; 280 328 }
