New upstream version 18.0.1+dfsg1

This commit is contained in:
Sebastian Ramacher 2017-04-19 21:54:15 +02:00
parent 6efda2859e
commit f2cf6cce50
1337 changed files with 41178 additions and 84670 deletions

View file

@ -23,6 +23,7 @@
#include <util/platform.h>
#include <libavutil/opt.h>
#include <libavutil/pixdesc.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
@ -35,6 +36,7 @@ struct ffmpeg_cfg {
const char *format_name;
const char *format_mime_type;
const char *muxer_settings;
int gop_size;
int video_bitrate;
int audio_bitrate;
const char *video_encoder;
@ -129,10 +131,12 @@ static bool new_stream(struct ffmpeg_data *data, AVStream **stream,
return true;
}
static void parse_params(AVCodecContext *context, char **opts)
static bool parse_params(AVCodecContext *context, char **opts)
{
bool ret = true;
if (!context || !context->priv_data)
return;
return true;
while (*opts) {
char *opt = *opts;
@ -145,11 +149,16 @@ static void parse_params(AVCodecContext *context, char **opts)
*assign = 0;
value = assign+1;
av_opt_set(context->priv_data, name, value, 0);
if (av_opt_set(context->priv_data, name, value, 0)) {
blog(LOG_WARNING, "Failed to set %s=%s", name, value);
ret = false;
}
}
opts++;
}
return ret;
}
static bool open_video_codec(struct ffmpeg_data *data)
@ -162,7 +171,9 @@ static bool open_video_codec(struct ffmpeg_data *data)
av_opt_set(context->priv_data, "preset", "veryfast", 0);
if (opts) {
parse_params(context, opts);
// libav requires x264 parameters in a special format which may be non-obvious
if (!parse_params(context, opts) && strcmp(data->vcodec->name, "libx264") == 0)
blog(LOG_WARNING, "If you're trying to set x264 parameters, use x264-params=name=value:name=value");
strlist_free(opts);
}
@ -238,7 +249,7 @@ static bool create_video_stream(struct ffmpeg_data *data)
context->width = data->config.scale_width;
context->height = data->config.scale_height;
context->time_base = (AVRational){ ovi.fps_den, ovi.fps_num };
context->gop_size = 120;
context->gop_size = data->config.gop_size;
context->pix_fmt = closest_format;
context->colorspace = data->config.color_space;
context->color_range = data->config.color_range;
@ -266,7 +277,7 @@ static bool create_video_stream(struct ffmpeg_data *data)
static bool open_audio_codec(struct ffmpeg_data *data)
{
AVCodecContext *context = data->audio->codec;
char **opts = strlist_split(data->config.video_settings, ' ', false);
char **opts = strlist_split(data->config.audio_settings, ' ', false);
int ret;
if (opts) {
@ -620,8 +631,10 @@ static void ffmpeg_output_destroy(void *data)
}
static inline void copy_data(AVPicture *pic, const struct video_data *frame,
int height)
int height, enum AVPixelFormat format)
{
int h_chroma_shift, v_chroma_shift;
av_pix_fmt_get_chroma_sub_sample(format, &h_chroma_shift, &v_chroma_shift);
for (int plane = 0; plane < MAX_AV_PLANES; plane++) {
if (!frame->data[plane])
continue;
@ -630,7 +643,7 @@ static inline void copy_data(AVPicture *pic, const struct video_data *frame,
int pic_rowsize = pic->linesize[plane];
int bytes = frame_rowsize < pic_rowsize ?
frame_rowsize : pic_rowsize;
int plane_height = plane == 0 ? height : height/2;
int plane_height = height >> (plane ? v_chroma_shift : 0);
for (int y = 0; y < plane_height; y++) {
int pos_frame = y * frame_rowsize;
@ -669,7 +682,7 @@ static void receive_video(void *param, struct video_data *frame)
0, data->config.height, data->dst_picture.data,
data->dst_picture.linesize);
else
copy_data(&data->dst_picture, frame, context->height);
copy_data(&data->dst_picture, frame, context->height, context->pix_fmt);
if (data->output->flags & AVFMT_RAWPICTURE) {
packet.flags |= AV_PKT_FLAG_KEY;
@ -939,6 +952,9 @@ static bool try_connect(struct ffmpeg_output *output)
int ret;
settings = obs_output_get_settings(output->output);
obs_data_set_default_int(settings, "gop_size", 120);
config.url = obs_data_get_string(settings, "url");
config.format_name = get_string_or_null(settings, "format_name");
config.format_mime_type = get_string_or_null(settings,
@ -946,6 +962,7 @@ static bool try_connect(struct ffmpeg_output *output)
config.muxer_settings = obs_data_get_string(settings, "muxer_settings");
config.video_bitrate = (int)obs_data_get_int(settings, "video_bitrate");
config.audio_bitrate = (int)obs_data_get_int(settings, "audio_bitrate");
config.gop_size = (int)obs_data_get_int(settings, "gop_size");
config.video_encoder = get_string_or_null(settings, "video_encoder");
config.video_encoder_id = (int)obs_data_get_int(settings,
"video_encoder_id");