Fix a number of MSVC warnings

Fixes a number of warnings with all modules
This commit is contained in:
jp9000
2017-12-05 13:53:18 -08:00
parent ffdecc34f4
commit 0d6204c8af
19 changed files with 185 additions and 101 deletions

View File

@@ -124,14 +124,14 @@ static inline void copy_data(struct ffmpeg_decode *decode, uint8_t *data,
memcpy(decode->packet_buffer, data, size);
}
int ffmpeg_decode_audio(struct ffmpeg_decode *decode,
bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
uint8_t *data, size_t size,
struct obs_source_audio *audio,
bool *got_output)
{
AVPacket packet = {0};
int got_frame = false;
int len;
int ret = 0;
*got_output = false;
@@ -144,32 +144,42 @@ int ffmpeg_decode_audio(struct ffmpeg_decode *decode,
if (!decode->frame) {
decode->frame = av_frame_alloc();
if (!decode->frame)
return -1;
return false;
}
len = avcodec_decode_audio4(decode->decoder, decode->frame, &got_frame,
&packet);
if (data && size)
ret = avcodec_send_packet(decode->decoder, &packet);
if (ret == 0)
ret = avcodec_receive_frame(decode->decoder, decode->frame);
if (len <= 0 || !got_frame)
return len;
got_frame = (ret == 0);
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
ret = 0;
if (ret < 0)
return false;
else if (ret == 0 || !got_frame)
return true;
for (size_t i = 0; i < MAX_AV_PLANES; i++)
audio->data[i] = decode->frame->data[i];
audio->samples_per_sec = decode->frame->sample_rate;
audio->speakers = convert_speaker_layout(decode->decoder->channels);
audio->format = convert_sample_format(decode->frame->format);
audio->speakers =
convert_speaker_layout((uint8_t)decode->decoder->channels);
audio->frames = decode->frame->nb_samples;
if (audio->format == AUDIO_FORMAT_UNKNOWN)
return 0;
return false;
*got_output = true;
return len;
return true;
}
int ffmpeg_decode_video(struct ffmpeg_decode *decode,
bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
uint8_t *data, size_t size, long long *ts,
struct obs_source_frame *frame,
bool *got_output)
@@ -177,7 +187,7 @@ int ffmpeg_decode_video(struct ffmpeg_decode *decode,
AVPacket packet = {0};
int got_frame = false;
enum video_format new_format;
int len;
int ret;
*got_output = false;
@@ -195,14 +205,22 @@ int ffmpeg_decode_video(struct ffmpeg_decode *decode,
if (!decode->frame) {
decode->frame = av_frame_alloc();
if (!decode->frame)
return -1;
return false;
}
len = avcodec_decode_video2(decode->decoder, decode->frame, &got_frame,
&packet);
ret = avcodec_send_packet(decode->decoder, &packet);
if (ret == 0)
ret = avcodec_receive_frame(decode->decoder, decode->frame);
if (len <= 0 || !got_frame)
return len;
got_frame = (ret == 0);
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
ret = 0;
if (ret < 0)
return false;
else if (ret == 0 || !got_frame)
return true;
for (size_t i = 0; i < MAX_AV_PLANES; i++) {
frame->data[i] = decode->frame->data[i];
@@ -228,7 +246,7 @@ int ffmpeg_decode_video(struct ffmpeg_decode *decode,
blog(LOG_ERROR, "Failed to get video format "
"parameters for video format %u",
VIDEO_CS_601);
return 0;
return false;
}
}
@@ -239,8 +257,8 @@ int ffmpeg_decode_video(struct ffmpeg_decode *decode,
frame->flip = false;
if (frame->format == VIDEO_FORMAT_NONE)
return 0;
return false;
*got_output = true;
return len;
return true;
}

View File

@@ -49,12 +49,12 @@ struct ffmpeg_decode {
extern int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id);
extern void ffmpeg_decode_free(struct ffmpeg_decode *decode);
extern int ffmpeg_decode_audio(struct ffmpeg_decode *decode,
extern bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
uint8_t *data, size_t size,
struct obs_source_audio *audio,
bool *got_output);
extern int ffmpeg_decode_video(struct ffmpeg_decode *decode,
extern bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
uint8_t *data, size_t size, long long *ts,
struct obs_source_frame *frame,
bool *got_output);

View File

@@ -433,9 +433,9 @@ void DShowInput::OnEncodedVideoData(enum AVCodecID id,
}
bool got_output;
int len = ffmpeg_decode_video(video_decoder, data, size, &ts,
bool success = ffmpeg_decode_video(video_decoder, data, size, &ts,
&frame, &got_output);
if (len < 0) {
if (!success) {
blog(LOG_WARNING, "Error decoding video");
return;
}
@@ -532,11 +532,11 @@ void DShowInput::OnEncodedAudioData(enum AVCodecID id,
}
}
bool got_output = false;
do {
bool got_output;
int len = ffmpeg_decode_audio(audio_decoder, data, size,
bool success = ffmpeg_decode_audio(audio_decoder, data, size,
&audio, &got_output);
if (len < 0) {
if (!success) {
blog(LOG_WARNING, "Error decoding audio");
return;
}
@@ -553,9 +553,9 @@ void DShowInput::OnEncodedAudioData(enum AVCodecID id,
ts += int64_t(audio_decoder->frame->nb_samples) * 10000000LL /
int64_t(audio_decoder->frame->sample_rate);
size -= (size_t)len;
data += len;
} while (size > 0);
size = 0;
data = nullptr;
} while (got_output);
}
void DShowInput::OnAudioData(const AudioConfig &config,
@@ -575,7 +575,7 @@ void DShowInput::OnAudioData(const AudioConfig &config,
return;
}
audio.speakers = convert_speaker_layout(config.channels);
audio.speakers = convert_speaker_layout((uint8_t)config.channels);
audio.format = ConvertAudioFormat(config.format);
audio.samples_per_sec = (uint32_t)config.sampleRate;
audio.data[0] = data;
@@ -759,7 +759,6 @@ static inline bool IsEncoded(const VideoConfig &config)
inline void DShowInput::SetupBuffering(obs_data_t *settings)
{
BufferingType bufType;
uint32_t flags = obs_source_get_flags(source);
bool useBuffering;
bufType = (BufferingType)obs_data_get_int(settings, BUFFERING_VAL);