summaryrefslogtreecommitdiff
path: root/output_example.c
diff options
context:
space:
mode:
authorLuca Abeni <lucabe72@email.it>2006-08-03 16:55:36 +0000
committerLuca Abeni <lucabe72@email.it>2006-08-03 16:55:36 +0000
commit03ae87a3e8cc8ab50c25626c1ff9e5fcc2267602 (patch)
tree431088ad2d084401ef061478405b3986330bace6 /output_example.c
parentdfeb80a5a97a9a6bbc48d7c7899308fa29714c8b (diff)
Move output_example.c and ffplay.c to the swscale interface
Originally committed as revision 5923 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'output_example.c')
-rw-r--r--output_example.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/output_example.c b/output_example.c
index 365a35e156..083bbe5cd6 100644
--- a/output_example.c
+++ b/output_example.c
@@ -32,6 +32,7 @@
#endif
#include "avformat.h"
+#include "swscale.h"
/* 5 seconds stream duration */
#define STREAM_DURATION 5.0
@@ -39,6 +40,8 @@
#define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE))
#define STREAM_PIX_FMT PIX_FMT_YUV420P /* default pix_fmt */
+static int sws_flags = SWS_BICUBIC;
+
/**************************************************************/
/* audio output */
@@ -319,6 +322,7 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st)
{
int out_size, ret;
AVCodecContext *c;
+ static struct SwsContext *img_convert_ctx;
c = st->codec;
@@ -330,10 +334,20 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st)
if (c->pix_fmt != PIX_FMT_YUV420P) {
/* as we only generate a YUV420P picture, we must convert it
to the codec pixel format if needed */
+ if (img_convert_ctx == NULL) {
+ img_convert_ctx = sws_getContext(c->width, c->height,
+ PIX_FMT_YUV420P,
+ c->width, c->height,
+ c->pix_fmt,
+ sws_flags, NULL, NULL, NULL);
+ if (img_convert_ctx == NULL) {
+ fprintf(stderr, "Cannot initialize the conversion context\n");
+ exit(1);
+ }
+ }
fill_yuv_image(tmp_picture, frame_count, c->width, c->height);
- img_convert((AVPicture *)picture, c->pix_fmt,
- (AVPicture *)tmp_picture, PIX_FMT_YUV420P,
- c->width, c->height);
+ sws_scale(img_convert_ctx, tmp_picture->data, tmp_picture->linesize,
+ 0, c->height, picture->data, picture->linesize);
} else {
fill_yuv_image(picture, frame_count, c->width, c->height);
}