summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-01-21 22:40:34 +0100
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-01-21 22:40:34 +0100
commit546456bdf813449585fa014a11384bcd7475bd41 (patch)
treed568560553c0a9f887a718a3408fa854ff49894e /modules
parentecf33122333fd7e6f4e70f93cc2c3baf3b22bdf3 (diff)
swscale: get dst-size from config (ref #203)
Diffstat (limited to 'modules')
-rw-r--r--modules/swscale/swscale.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/modules/swscale/swscale.c b/modules/swscale/swscale.c
index 5b2399c..7c26c63 100644
--- a/modules/swscale/swscale.c
+++ b/modules/swscale/swscale.c
@@ -14,6 +14,7 @@ struct swscale_enc {
struct SwsContext *sws;
struct vidframe *frame;
+ struct vidsz dst_size;
};
@@ -47,8 +48,14 @@ static int encode_update(struct vidfilt_enc_st **stp, void **ctx,
const struct vidfilt *vf)
{
struct swscale_enc *st;
+ struct config *config = conf_config();
int err = 0;
+ if (!config) {
+ warning("swscale: no config\n");
+ return EINVAL;
+ }
+
if (!stp || !ctx || !vf)
return EINVAL;
@@ -59,6 +66,9 @@ static int encode_update(struct vidfilt_enc_st **stp, void **ctx,
if (!st)
return ENOMEM;
+ st->dst_size.w = config->video.width;
+ st->dst_size.h = config->video.height;
+
if (err)
mem_deref(st);
else
@@ -107,7 +117,8 @@ static int encode_process(struct vidfilt_enc_st *st, struct vidframe *frame)
int flags = 0;
sws = sws_getContext(width, height, avpixfmt,
- width, height, avpixfmt_dst,
+ enc->dst_size.w, enc->dst_size.h,
+ avpixfmt_dst,
flags, NULL, NULL, NULL);
if (!sws) {
warning("swscale: sws_getContext error\n");
@@ -116,15 +127,17 @@ static int encode_process(struct vidfilt_enc_st *st, struct vidframe *frame)
enc->sws = sws;
- info("swscale: created SwsContext: `%s' --> `%s'\n",
- vidfmt_name(frame->fmt),
- vidfmt_name(swscale_format));
+ info("swscale: created SwsContext:"
+ " `%s' %d x %d --> `%s' %u x %u\n",
+ vidfmt_name(frame->fmt), width, height,
+ vidfmt_name(swscale_format),
+ enc->dst_size.w, enc->dst_size.h);
}
if (!enc->frame) {
err = vidframe_alloc(&enc->frame, swscale_format,
- &frame->size);
+ &enc->dst_size);
if (err) {
warning("swscale: vidframe_alloc error (%m)\n", err);
return err;