summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2012-03-05 22:24:57 +0100
committerwm4 <wm4@mplayer2.org>2012-03-05 22:24:57 +0100
commit8dc0743571630a08fd40fa88aa09b12b4ce65bf2 (patch)
treee1c4465768635d77954b5fd21ae726444ee4f48a /libvo
parentaebdf4f153438497b9310bd1417b5216f07e043b (diff)
parentafecdb681bed81b5df0ed18a300c68be603dfdf9 (diff)
downloadmpv-8dc0743571630a08fd40fa88aa09b12b4ce65bf2.tar.bz2
mpv-8dc0743571630a08fd40fa88aa09b12b4ce65bf2.tar.xz
Merge remote-tracking branch 'origin/master' into my_master
Conflicts: mplayer.c screenshot.c
Diffstat (limited to 'libvo')
-rw-r--r--libvo/video_out.c4
-rw-r--r--libvo/video_out.h1
-rw-r--r--libvo/vo_png.c33
-rw-r--r--libvo/vo_sdl.c2
4 files changed, 26 insertions, 14 deletions
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 1099fdffec..1d81000795 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -281,7 +281,7 @@ int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts)
int vo_redraw_frame(struct vo *vo)
{
- if (!vo->config_ok)
+ if (!vo->config_ok || !vo->hasframe)
return -1;
if (vo_control(vo, VOCTRL_REDRAW_FRAME, NULL) == true) {
vo->redrawing = true;
@@ -354,6 +354,7 @@ void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration)
vo->driver->flip_page_timed(vo, pts_us, duration);
else
vo->driver->flip_page(vo);
+ vo->hasframe = true;
}
void vo_check_events(struct vo *vo)
@@ -496,6 +497,7 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height,
vo->frame_loaded = false;
vo->waiting_mpi = NULL;
vo->redrawing = false;
+ vo->hasframe = false;
return ret;
}
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 06c606f4d2..554b97d207 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -265,6 +265,7 @@ struct vo {
double next_pts2; // optional pts of frame after that
bool want_redraw; // visible frame wrong (window resize), needs refresh
bool redrawing; // between redrawing frame and flipping it
+ bool hasframe; // >= 1 frame has been drawn, so redraw is possible
double flip_queue_offset; // queue flip events at most this much in advance
diff --git a/libvo/vo_png.c b/libvo/vo_png.c
index 5ad683ad22..6e23bafd5f 100644
--- a/libvo/vo_png.c
+++ b/libvo/vo_png.c
@@ -63,8 +63,24 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
}
mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression);
-
+ uninit();
+ struct AVCodec *png_codec = avcodec_find_encoder(CODEC_ID_PNG);
+ if (!png_codec)
+ goto error;
+ avctx = avcodec_alloc_context3(png_codec);
+ if (!avctx)
+ goto error;
+ avctx->width = width;
+ avctx->height = height;
+ avctx->pix_fmt = imgfmt2pixfmt(format);
+ avctx->compression_level = z_compression;
+ if (avcodec_open2(avctx, png_codec, NULL) < 0)
+ goto error;
return 0;
+
+ error:
+ uninit();
+ return -1;
}
@@ -85,9 +101,6 @@ static uint32_t draw_image(mp_image_t* mpi){
return 1;
}
- avctx->width = mpi->w;
- avctx->height = mpi->h;
- avctx->pix_fmt = imgfmt2pixfmt(mpi->imgfmt);
pic.data[0] = mpi->planes[0];
pic.linesize[0] = mpi->stride[0];
buffersize = mpi->w * mpi->h * 8;
@@ -137,8 +150,10 @@ query_format(uint32_t format)
return 0;
}
-static void uninit(void){
- avcodec_close(avctx);
+static void uninit(void)
+{
+ if (avctx)
+ avcodec_close(avctx);
av_freep(&avctx);
av_freep(&outbuffer);
outbuffer_size = 0;
@@ -165,12 +180,6 @@ static int preinit(const char *arg)
if (subopt_parse(arg, subopts) != 0) {
return -1;
}
- avctx = avcodec_alloc_context();
- if (avcodec_open(avctx, avcodec_find_encoder(CODEC_ID_PNG)) < 0) {
- uninit();
- return -1;
- }
- avctx->compression_level = z_compression;
return 0;
}
diff --git a/libvo/vo_sdl.c b/libvo/vo_sdl.c
index ae16d0e599..71cf75323a 100644
--- a/libvo/vo_sdl.c
+++ b/libvo/vo_sdl.c
@@ -66,7 +66,7 @@
#include "sub/sub.h"
#include "aspect.h"
#include "libmpcodecs/vfcap.h"
-#include "ffmpeg_files/bswap.h"
+#include "mpbswap.h"
#ifdef CONFIG_X11
#include <X11/Xlib.h>