[MOVIE_LOADER] Fix hang up at end of video.
[MOVIE_SAVER][WIP] Fixing crash when saving movie and playing video.(still not fix).
message("* qt/osd")
-SET(THIS_LIB_VERSION 2.10.3)
+SET(THIS_LIB_VERSION 2.10.4)
set(s_qt_osd_headers
osd_base.h
message("* qt/avio")
-SET(THIS_LIB_VERSION 2.7.2)
+SET(THIS_LIB_VERSION 2.7.3)
set(s_qt_avio_headers
movie_saver.h
movie_loader.h
dst_width, dst_height,
AV_PIX_FMT_BGRA,
SCALE_FLAGS, NULL, NULL, NULL);
+ //csp_logger->debug_log(CSP_LOG_DEBUG, CSP_LOG_TYPE_MOVIE_LOADER, "Src frame=%dx%d Allocate frame: %dx%d", frame->width, frame->height, dst_width, dst_height);
+
if (sws_context == NULL) {
csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_MOVIE_LOADER,
"MOVIE_LOADER: Could not initialize the conversion context\n");
video_mutex->lock();
sws_scale(sws_context,
frame->data, frame->linesize,
- 0, dst_height, video_dst_data, video_dst_linesize);
+ 0, frame->height, video_dst_data, video_dst_linesize);
req_transfer = true;
video_mutex->unlock();
}
bool end_of_frame = false;
int real_frames = 0;
double d_frames = (double)frames * (frame_rate / p_osd->vm_frame_rate());
+ if(now_pausing) return;
if(now_playing) duration_us = duration_us + (int64_t)((1.0e6 * (double)frames) / p_osd->vm_frame_rate());
mod_frames = mod_frames + d_frames;
a_f = (av_rescale_rnd(audio_total_samples, 1000000, audio_stream->codec->sample_rate, AV_ROUND_UP) < duration_us);
//csp_logger->debug_log(CSP_LOG_DEBUG, CSP_LOG_TYPE_MOVIE_LOADER, "%lld usec. V=%lld A=%lld, %d - %d\n", duration_us, video_frame_count, audio_total_samples, v_f, a_f);
if(!a_f && !v_f) break;
- av_read_frame(fmt_ctx, &pkt);
+ if(av_read_frame(fmt_ctx, &pkt) < 0) {
+ this->close();
+ return;
+ }
decode_packet(&got_frame, 0);
if(got_frame == 0) {
end_of_frame = true;
QMutexLocker Locker_S(p_osd->screen_mutex);
QMutexLocker Locker_V(video_mutex);
+
if(req_transfer) {
+ //csp_logger->debug_log(CSP_LOG_DEBUG, CSP_LOG_TYPE_MOVIE_LOADER, "Transfer frame: %dx%d", dst_width, dst_height);
req_transfer = false;
for(int yy = 0; yy < dst_height; yy++) {
q = (uint32_t *)(p_osd->get_vm_screen_buffer(yy));
p = (uint32_t *)(&(video_dst_data[0][yy * video_dst_linesize[0]]));
if((p == NULL) || (q == NULL)) break;
for(xx = dst_width; xx > 7;) {
- cacheline[0] = p[0];
- cacheline[1] = p[1];
- cacheline[2] = p[2];
- cacheline[3] = p[3];
- cacheline[4] = p[4];
- cacheline[5] = p[5];
- cacheline[6] = p[6];
- cacheline[7] = p[7];
-
- q[0] = cacheline[0];
- q[1] = cacheline[1];
- q[2] = cacheline[2];
- q[3] = cacheline[3];
- q[4] = cacheline[4];
- q[5] = cacheline[5];
- q[6] = cacheline[6];
- q[7] = cacheline[7];
-
+__DECL_VECTORIZED_LOOP
+ for(int i = 0; i < 8; i++) {
+ cacheline[i] = p[i];
+ q[i] = cacheline[i];
+ }
p += 8;
q += 8;
xx -= 8;
uint32_t col = 0xffffffff;
if(q == NULL) break;
for(xx = dst_width; xx > 7;) {
-
- q[0] = col;
- q[1] = col;
- q[2] = col;
- q[3] = col;
- q[4] = col;
- q[5] = col;
- q[6] = col;
- q[7] = col;
-
+__DECL_VECTORIZED_LOOP
+ for(int i = 0; i < 8; i++) {
+ q[i] = col;
+ }
p += 8;
q += 8;
xx -= 8;
if(xx < 8) break;
}
for(; xx > 0; xx--) {
- *q++ = *p++;
+ *q++ = col;
}
#endif
}
// Copy from FFMPEG-3.0.2; doc/example/muxing.c .
#define STREAM_PIX_FMT AV_PIX_FMT_RGBA /* default pix_fmt */
-#define SCALE_FLAGS SWS_BICUBLIN
+//#define SCALE_FLAGS SWS_BICUBLIN
//#define SCALE_FLAGS SWS_POINT
+#define SCALE_FLAGS SWS_FAST_BILINEAR
#include <QObject>
#include <QReadWriteLock>
MOVIE_SAVER::~MOVIE_SAVER()
{
+ req_close = true;
if(recording) do_close_main();
- //if(video_queue_mutex) delete video_queue_mutex;
-
}
QString MOVIE_SAVER::ts2str(int64_t ts)
if(!recording) return;
if(p == NULL) return;
if(req_stop) return;
+ if((width <= 0) || (height <= 0) || (frames <= 0)) return;
+ if((p->width() <= 0) || (p->height() <= 0)) return;
VIDEO_DATA *px = new VIDEO_DATA(frames, width, height, p);
//csp_logger->debug_log(CSP_LOG_DEBUG, CSP_LOG_TYPE_MOVIE_SAVER, "Movie: Enqueue video data %dx%d %d bytes %dx%d %d frames", width, height, p->byteCount(), p->width(), p->height(), frames);
//video_queue_mutex->lock();
my_memcpy(&(p[_width * y]), pq, (((uint)_width * sizeof(uint32_t)) > pp_i->bytesPerLine()) ? pp_i->bytesPerLine() : _width * sizeof(uint32_t));
}
video_size = _width * y;
- //csp_logger->debug_log(CSP_LOG_DEBUG, CSP_LOG_TYPE_MOVIE_SAVER, "Movie: Dequeue video data %d bytes", pp->byteCount());
+ //csp_logger->debug_log(CSP_LOG_DEBUG, CSP_LOG_TYPE_MOVIE_SAVER, "Movie: Dequeue video data %d bytes", video_size);
}
#else
video_size = 0;
void OSD_BASE::do_draw(bool flag)
{
int frames;
+#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
do_decode_movie(1);
+#endif
if(flag) {
frames = draw_screen();
} else {
buffer->pImage = QImage(width, height, QImage::Format_ARGB32);
buffer->pImage.fill(col);
}
- //printf("%dx%d NULL=%d\n", buffer->pImage.width(), buffer->pImage.height(), buffer->pImage.isNull() ? 1 : 0);
+ printf("%dx%d NULL=%d\n", buffer->pImage.width(), buffer->pImage.height(), buffer->pImage.isNull() ? 1 : 0);
QColor fillcolor;
fillcolor.setRgb(0, 0, 0, 255);
buffer->pImage.fill(fillcolor);
void OSD::do_decode_movie(int frames)
{
#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
- movie_loader->do_decode_frames(frames, this->get_vm_window_width(), this->get_vm_window_height());
+ //movie_loader->do_decode_frames(frames, SCREEN_WIDTH, SCREEN_HEIGHT);
+ movie_loader->do_decode_frames(frames, vm_window_width_aspect, vm_window_height_aspect);
#endif
}