void ReplayPreview::run_thread( ) { Mjpeg422Decoder dec(1920, 1080); ReplayFrameData rfd; ReplayRawFrame *monitor_frame; RawFrame *new_frame; for (;;) { try { /* wait for some work to do */ wait_update(rfd); /* decode at 960 max width */ new_frame = dec.decode(rfd.main_jpeg( ), rfd.main_jpeg_size( ), 960); /* send to multiview */ monitor_frame = new ReplayRawFrame(new_frame->convert->BGRAn8( )); delete new_frame; /* fill in timecode and source info for monitor */ monitor_frame->source_name = "Preview"; monitor_frame->source_name2 = rfd.source->get_name( ); monitor_frame->tc = rfd.pos; monitor.put(monitor_frame); } catch (ReplayFrameNotFoundException &e) { fprintf(stderr, "replay preview: frame not found\n"); find_closest_valid_frame( ); } } }
void RolloutPreview::run_thread( ) { std::string current_file; std::string new_file; ReplayPlayoutLavfSource *current_source = NULL; ReplayPlayoutFrame frame_data; Rational speed(1,1); RawFrame *img; ReplayRawFrame *monitor_frame; int64_t current_pos, new_pos; bool do_update; for (;;) { /* wait for some work to do */ wait_update(new_file, new_pos); do_update = false; /* if we are going to a new file, open the file */ if (new_file != current_file) { if (current_source != NULL) { delete current_source; current_source = NULL; } current_source = new ReplayPlayoutLavfSource(new_file.c_str()); current_file = new_file; current_pos = 0; do_update = true; } /* if we have a new position, seek the file */ if (new_pos != current_pos) { current_pos = new_pos; do_update = true; if (current_source != NULL) { current_source->seek(new_pos); } } if (do_update && current_source != NULL) { /* decode a frame of video */ current_source->read_frame(frame_data, speed); img = frame_data.video_data; /* put 1/2 scale version to multiviewer */ monitor_frame = new ReplayRawFrame(img->convert->BGRAn8_scale_1_2()); monitor_frame->source_name = "Preview"; monitor_frame->source_name2 = current_file.c_str(); monitor_frame->tc = 0; monitor.put(monitor_frame); /* delete decoded data so we don't leak it */ delete frame_data.video_data; delete frame_data.audio_data; } } }
void read_rtc(struct rtc_date_time *dt) { int last_second; int last_minute; int last_hour; int last_day; int last_month; int last_year; int last_century; int registerB; if (!dt) { return; } /* * Note: This uses the "read registers until you get the same values twice in a row" technique * to avoid getting dodgy/inconsistent values due to rtc updates */ // Make sure an update isn't in progress wait_update(); dt->second = read_rtc_reg(0x00); dt->minute = read_rtc_reg(0x02); dt->hour = read_rtc_reg(0x04); dt->day = read_rtc_reg(0x07); dt->month = read_rtc_reg(0x08); dt->year = read_rtc_reg(0x09); if (century_reg) { dt->century = read_rtc_reg(century_reg); } do { last_second = dt->second; last_minute = dt->minute; last_hour = dt->hour; last_day = dt->day; last_month = dt->month; last_year = dt->year; last_century = dt->century; // Make sure an update isn't in progress wait_update(); dt->second = read_rtc_reg(0x00); dt->minute = read_rtc_reg(0x02); dt->hour = read_rtc_reg(0x04); dt->day = read_rtc_reg(0x07); dt->month = read_rtc_reg(0x08); dt->year = read_rtc_reg(0x09); if (century_reg) { dt->century = read_rtc_reg(century_reg); } } while ( (last_second == dt->second) && (last_minute == dt->minute) && (last_hour == dt->hour) && (last_day == dt->day) && (last_month == dt->month) && (last_year == dt->year) && (last_century == dt->century) ); registerB = read_rtc_reg(0x0B); // Convert BCD to binary values if necessary if (!(registerB & 0x04)) { dt->second = (dt->second & 0x0F) + ((dt->second / 16) * 10); dt->minute = (dt->minute & 0x0F) + ((dt->minute / 16) * 10); dt->hour = ((dt->hour & 0x0F) + (((dt->hour & 0x70) / 16) * 10)) | (dt->hour & 0x80); dt->day = (dt->day & 0x0F) + ((dt->day / 16) * 10); dt->month = (dt->month & 0x0F) + ((dt->month / 16) * 10); dt->year = (dt->year & 0x0F) + ((dt->year / 16) * 10); if(century_reg) { dt->century = (dt->century & 0x0F) + ((dt->century / 16) * 10); } } // Convert 12 hour clock to 24 hour clock if necessary if (!(registerB & 0x02) && (dt->hour & 0x80)) { dt->hour = ((dt->hour & 0x7F) + 12) % 24; } // Calculate the full (4-digit) year if(century_reg) { dt->year += dt->century * 100; } else { if (dt->year > 80 && dt->year < 100) { dt->century = 20; dt->year += 1900; } else { dt->century = 21; dt->year += 2000; } //year += (CURRENT_YEAR / 100) * 100; //if (year < CURRENT_YEAR) year += 100; } }