obs-ffmpeg: Normalize ffmpeg source argument name

This commit is contained in:
John Bradley 2015-08-03 15:28:46 -05:00 committed by kc5nra
parent 59482ec29b
commit 207203d104

View File

@ -131,13 +131,13 @@ static bool set_obs_frame_colorprops(struct ff_frame *frame,
return true; return true;
} }
bool update_sws_context(struct ffmpeg_source *source, AVFrame *frame) bool update_sws_context(struct ffmpeg_source *s, AVFrame *frame)
{ {
if (frame->width != source->sws_width if (frame->width != s->sws_width
|| frame->height != source->sws_height || frame->height != s->sws_height
|| frame->format != source->sws_format) { || frame->format != s->sws_format) {
if (source->sws_ctx != NULL) if (s->sws_ctx != NULL)
sws_freeContext(source->sws_ctx); sws_freeContext(s->sws_ctx);
if (frame->width <= 0 || frame->height <= 0) { if (frame->width <= 0 || frame->height <= 0) {
av_log(NULL, AV_LOG_ERROR, "unable to create a sws " av_log(NULL, AV_LOG_ERROR, "unable to create a sws "
@ -147,7 +147,7 @@ bool update_sws_context(struct ffmpeg_source *source, AVFrame *frame)
goto fail; goto fail;
} }
source->sws_ctx = sws_getContext( s->sws_ctx = sws_getContext(
frame->width, frame->width,
frame->height, frame->height,
frame->format, frame->format,
@ -157,7 +157,7 @@ bool update_sws_context(struct ffmpeg_source *source, AVFrame *frame)
SWS_BILINEAR, SWS_BILINEAR,
NULL, NULL, NULL); NULL, NULL, NULL);
if (source->sws_ctx == NULL) { if (s->sws_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR, "unable to create sws " av_log(NULL, AV_LOG_ERROR, "unable to create sws "
"context with src{w:%d,h:%d,f:%d}->" "context with src{w:%d,h:%d,f:%d}->"
"dst{w:%d,h:%d,f:%d}", "dst{w:%d,h:%d,f:%d}",
@ -168,37 +168,37 @@ bool update_sws_context(struct ffmpeg_source *source, AVFrame *frame)
} }
if (source->sws_data != NULL) if (s->sws_data != NULL)
bfree(source->sws_data); bfree(s->sws_data);
source->sws_data = bzalloc(frame->width * frame->height * 4); s->sws_data = bzalloc(frame->width * frame->height * 4);
if (source->sws_data == NULL) { if (s->sws_data == NULL) {
av_log(NULL, AV_LOG_ERROR, "unable to allocate sws " av_log(NULL, AV_LOG_ERROR, "unable to allocate sws "
"pixel data with size %d", "pixel data with size %d",
frame->width * frame->height * 4); frame->width * frame->height * 4);
goto fail; goto fail;
} }
source->sws_linesize = frame->width * 4; s->sws_linesize = frame->width * 4;
source->sws_width = frame->width; s->sws_width = frame->width;
source->sws_height = frame->height; s->sws_height = frame->height;
source->sws_format = frame->format; s->sws_format = frame->format;
} }
return true; return true;
fail: fail:
if (source->sws_ctx != NULL) if (s->sws_ctx != NULL)
sws_freeContext(source->sws_ctx); sws_freeContext(s->sws_ctx);
source->sws_ctx = NULL; s->sws_ctx = NULL;
if (source->sws_data) if (s->sws_data)
bfree(source->sws_data); bfree(s->sws_data);
source->sws_data = NULL; s->sws_data = NULL;
source->sws_linesize = 0; s->sws_linesize = 0;
source->sws_width = 0; s->sws_width = 0;
source->sws_height = 0; s->sws_height = 0;
source->sws_format = 0; s->sws_format = 0;
return false; return false;
} }