clang-format: Apply formatting
Code submissions have continually suffered from formatting inconsistencies that constantly have to be addressed. Using clang-format simplifies this by making code formatting more consistent, and allows automation of the code formatting so that maintainers can focus more on the code itself instead of code formatting.
This commit is contained in:
@@ -35,7 +35,7 @@ set(libdshowcapture_SOURCES
|
||||
|
||||
set(libdshowcapture_HEADERS
|
||||
libdshowcapture/dshowcapture.hpp
|
||||
libdshowcapture/source/IVideoCaptureFilter.h
|
||||
libdshowcapture/source/external/IVideoCaptureFilter.h
|
||||
libdshowcapture/source/capture-filter.hpp
|
||||
libdshowcapture/source/output-filter.hpp
|
||||
libdshowcapture/source/device.hpp
|
||||
|
@@ -15,7 +15,8 @@ static inline void decode_dstr(struct dstr *str)
|
||||
}
|
||||
|
||||
static inline void EncodeDeviceId(struct dstr *encodedStr,
|
||||
const wchar_t *name_str, const wchar_t *path_str)
|
||||
const wchar_t *name_str,
|
||||
const wchar_t *path_str)
|
||||
{
|
||||
DStr name;
|
||||
DStr path;
|
||||
@@ -32,7 +33,7 @@ static inline void EncodeDeviceId(struct dstr *encodedStr,
|
||||
}
|
||||
|
||||
static inline bool DecodeDeviceDStr(DStr &name, DStr &path,
|
||||
const char *device_id)
|
||||
const char *device_id)
|
||||
{
|
||||
const char *path_str;
|
||||
|
||||
@@ -43,12 +44,12 @@ static inline bool DecodeDeviceDStr(DStr &name, DStr &path,
|
||||
if (!path_str)
|
||||
return false;
|
||||
|
||||
dstr_copy(path, path_str+1);
|
||||
dstr_copy(path, path_str + 1);
|
||||
dstr_copy(name, device_id);
|
||||
|
||||
size_t len = path_str - device_id;
|
||||
name->array[len] = 0;
|
||||
name->len = len;
|
||||
name->len = len;
|
||||
|
||||
decode_dstr(name);
|
||||
decode_dstr(path);
|
||||
@@ -73,4 +74,3 @@ static inline bool DecodeDeviceId(DShow::DeviceId &out, const char *device_id)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -63,15 +63,23 @@ void ffmpeg_decode_free(struct ffmpeg_decode *decode)
|
||||
static inline enum video_format convert_pixel_format(int f)
|
||||
{
|
||||
switch (f) {
|
||||
case AV_PIX_FMT_NONE: return VIDEO_FORMAT_NONE;
|
||||
case AV_PIX_FMT_NONE:
|
||||
return VIDEO_FORMAT_NONE;
|
||||
case AV_PIX_FMT_YUV420P:
|
||||
case AV_PIX_FMT_YUVJ420P: return VIDEO_FORMAT_I420;
|
||||
case AV_PIX_FMT_NV12: return VIDEO_FORMAT_NV12;
|
||||
case AV_PIX_FMT_YUYV422: return VIDEO_FORMAT_YUY2;
|
||||
case AV_PIX_FMT_UYVY422: return VIDEO_FORMAT_UYVY;
|
||||
case AV_PIX_FMT_RGBA: return VIDEO_FORMAT_RGBA;
|
||||
case AV_PIX_FMT_BGRA: return VIDEO_FORMAT_BGRA;
|
||||
case AV_PIX_FMT_BGR0: return VIDEO_FORMAT_BGRX;
|
||||
case AV_PIX_FMT_YUVJ420P:
|
||||
return VIDEO_FORMAT_I420;
|
||||
case AV_PIX_FMT_NV12:
|
||||
return VIDEO_FORMAT_NV12;
|
||||
case AV_PIX_FMT_YUYV422:
|
||||
return VIDEO_FORMAT_YUY2;
|
||||
case AV_PIX_FMT_UYVY422:
|
||||
return VIDEO_FORMAT_UYVY;
|
||||
case AV_PIX_FMT_RGBA:
|
||||
return VIDEO_FORMAT_RGBA;
|
||||
case AV_PIX_FMT_BGRA:
|
||||
return VIDEO_FORMAT_BGRA;
|
||||
case AV_PIX_FMT_BGR0:
|
||||
return VIDEO_FORMAT_BGRX;
|
||||
default:;
|
||||
}
|
||||
|
||||
@@ -81,14 +89,22 @@ static inline enum video_format convert_pixel_format(int f)
|
||||
static inline enum audio_format convert_sample_format(int f)
|
||||
{
|
||||
switch (f) {
|
||||
case AV_SAMPLE_FMT_U8: return AUDIO_FORMAT_U8BIT;
|
||||
case AV_SAMPLE_FMT_S16: return AUDIO_FORMAT_16BIT;
|
||||
case AV_SAMPLE_FMT_S32: return AUDIO_FORMAT_32BIT;
|
||||
case AV_SAMPLE_FMT_FLT: return AUDIO_FORMAT_FLOAT;
|
||||
case AV_SAMPLE_FMT_U8P: return AUDIO_FORMAT_U8BIT_PLANAR;
|
||||
case AV_SAMPLE_FMT_S16P: return AUDIO_FORMAT_16BIT_PLANAR;
|
||||
case AV_SAMPLE_FMT_S32P: return AUDIO_FORMAT_32BIT_PLANAR;
|
||||
case AV_SAMPLE_FMT_FLTP: return AUDIO_FORMAT_FLOAT_PLANAR;
|
||||
case AV_SAMPLE_FMT_U8:
|
||||
return AUDIO_FORMAT_U8BIT;
|
||||
case AV_SAMPLE_FMT_S16:
|
||||
return AUDIO_FORMAT_16BIT;
|
||||
case AV_SAMPLE_FMT_S32:
|
||||
return AUDIO_FORMAT_32BIT;
|
||||
case AV_SAMPLE_FMT_FLT:
|
||||
return AUDIO_FORMAT_FLOAT;
|
||||
case AV_SAMPLE_FMT_U8P:
|
||||
return AUDIO_FORMAT_U8BIT_PLANAR;
|
||||
case AV_SAMPLE_FMT_S16P:
|
||||
return AUDIO_FORMAT_16BIT_PLANAR;
|
||||
case AV_SAMPLE_FMT_S32P:
|
||||
return AUDIO_FORMAT_32BIT_PLANAR;
|
||||
case AV_SAMPLE_FMT_FLTP:
|
||||
return AUDIO_FORMAT_FLOAT_PLANAR;
|
||||
default:;
|
||||
}
|
||||
|
||||
@@ -98,37 +114,45 @@ static inline enum audio_format convert_sample_format(int f)
|
||||
static inline enum speaker_layout convert_speaker_layout(uint8_t channels)
|
||||
{
|
||||
switch (channels) {
|
||||
case 0: return SPEAKERS_UNKNOWN;
|
||||
case 1: return SPEAKERS_MONO;
|
||||
case 2: return SPEAKERS_STEREO;
|
||||
case 3: return SPEAKERS_2POINT1;
|
||||
case 4: return SPEAKERS_4POINT0;
|
||||
case 5: return SPEAKERS_4POINT1;
|
||||
case 6: return SPEAKERS_5POINT1;
|
||||
case 8: return SPEAKERS_7POINT1;
|
||||
default: return SPEAKERS_UNKNOWN;
|
||||
case 0:
|
||||
return SPEAKERS_UNKNOWN;
|
||||
case 1:
|
||||
return SPEAKERS_MONO;
|
||||
case 2:
|
||||
return SPEAKERS_STEREO;
|
||||
case 3:
|
||||
return SPEAKERS_2POINT1;
|
||||
case 4:
|
||||
return SPEAKERS_4POINT0;
|
||||
case 5:
|
||||
return SPEAKERS_4POINT1;
|
||||
case 6:
|
||||
return SPEAKERS_5POINT1;
|
||||
case 8:
|
||||
return SPEAKERS_7POINT1;
|
||||
default:
|
||||
return SPEAKERS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void copy_data(struct ffmpeg_decode *decode, uint8_t *data,
|
||||
size_t size)
|
||||
size_t size)
|
||||
{
|
||||
size_t new_size = size + INPUT_BUFFER_PADDING_SIZE;
|
||||
|
||||
if (decode->packet_size < new_size) {
|
||||
decode->packet_buffer = brealloc(decode->packet_buffer,
|
||||
new_size);
|
||||
decode->packet_size = new_size;
|
||||
decode->packet_buffer =
|
||||
brealloc(decode->packet_buffer, new_size);
|
||||
decode->packet_size = new_size;
|
||||
}
|
||||
|
||||
memset(decode->packet_buffer + size, 0, INPUT_BUFFER_PADDING_SIZE);
|
||||
memcpy(decode->packet_buffer, data, size);
|
||||
}
|
||||
|
||||
bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
|
||||
uint8_t *data, size_t size,
|
||||
struct obs_source_audio *audio,
|
||||
bool *got_output)
|
||||
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;
|
||||
@@ -167,8 +191,8 @@ bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
|
||||
audio->data[i] = decode->frame->data[i];
|
||||
|
||||
audio->samples_per_sec = decode->frame->sample_rate;
|
||||
audio->format = convert_sample_format(decode->frame->format);
|
||||
audio->speakers =
|
||||
audio->format = convert_sample_format(decode->frame->format);
|
||||
audio->speakers =
|
||||
convert_speaker_layout((uint8_t)decode->decoder->channels);
|
||||
|
||||
audio->frames = decode->frame->nb_samples;
|
||||
@@ -180,10 +204,9 @@ bool ffmpeg_decode_audio(struct ffmpeg_decode *decode,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
uint8_t *data, size_t size, long long *ts,
|
||||
struct obs_source_frame2 *frame,
|
||||
bool *got_output)
|
||||
bool ffmpeg_decode_video(struct ffmpeg_decode *decode, uint8_t *data,
|
||||
size_t size, long long *ts,
|
||||
struct obs_source_frame2 *frame, bool *got_output)
|
||||
{
|
||||
AVPacket packet = {0};
|
||||
int got_frame = false;
|
||||
@@ -195,12 +218,12 @@ bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
copy_data(decode, data, size);
|
||||
|
||||
av_init_packet(&packet);
|
||||
packet.data = decode->packet_buffer;
|
||||
packet.size = (int)size;
|
||||
packet.pts = *ts;
|
||||
packet.data = decode->packet_buffer;
|
||||
packet.size = (int)size;
|
||||
packet.pts = *ts;
|
||||
|
||||
if (decode->codec->id == AV_CODEC_ID_H264 &&
|
||||
obs_avc_keyframe(data, size))
|
||||
obs_avc_keyframe(data, size))
|
||||
packet.flags |= AV_PKT_FLAG_KEY;
|
||||
|
||||
if (!decode->frame) {
|
||||
@@ -224,7 +247,7 @@ bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
return true;
|
||||
|
||||
for (size_t i = 0; i < MAX_AV_PLANES; i++) {
|
||||
frame->data[i] = decode->frame->data[i];
|
||||
frame->data[i] = decode->frame->data[i];
|
||||
frame->linesize[i] = decode->frame->linesize[i];
|
||||
}
|
||||
|
||||
@@ -234,25 +257,26 @@ bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
|
||||
frame->format = new_format;
|
||||
frame->range = decode->frame->color_range == AVCOL_RANGE_JPEG
|
||||
? VIDEO_RANGE_FULL
|
||||
: VIDEO_RANGE_DEFAULT;
|
||||
? VIDEO_RANGE_FULL
|
||||
: VIDEO_RANGE_DEFAULT;
|
||||
|
||||
success = video_format_get_parameters(VIDEO_CS_601,
|
||||
frame->range, frame->color_matrix,
|
||||
frame->color_range_min, frame->color_range_max);
|
||||
success = video_format_get_parameters(
|
||||
VIDEO_CS_601, frame->range, frame->color_matrix,
|
||||
frame->color_range_min, frame->color_range_max);
|
||||
if (!success) {
|
||||
blog(LOG_ERROR, "Failed to get video format "
|
||||
"parameters for video format %u",
|
||||
VIDEO_CS_601);
|
||||
blog(LOG_ERROR,
|
||||
"Failed to get video format "
|
||||
"parameters for video format %u",
|
||||
VIDEO_CS_601);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*ts = decode->frame->pkt_pts;
|
||||
|
||||
frame->width = decode->frame->width;
|
||||
frame->width = decode->frame->width;
|
||||
frame->height = decode->frame->height;
|
||||
frame->flip = false;
|
||||
frame->flip = false;
|
||||
|
||||
if (frame->format == VIDEO_FORMAT_NONE)
|
||||
return false;
|
||||
|
@@ -38,26 +38,25 @@ extern "C" {
|
||||
|
||||
struct ffmpeg_decode {
|
||||
AVCodecContext *decoder;
|
||||
AVCodec *codec;
|
||||
AVCodec *codec;
|
||||
|
||||
AVFrame *frame;
|
||||
AVFrame *frame;
|
||||
|
||||
uint8_t *packet_buffer;
|
||||
size_t packet_size;
|
||||
uint8_t *packet_buffer;
|
||||
size_t packet_size;
|
||||
};
|
||||
|
||||
extern int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id);
|
||||
extern void ffmpeg_decode_free(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 bool ffmpeg_decode_audio(struct ffmpeg_decode *decode, uint8_t *data,
|
||||
size_t size, struct obs_source_audio *audio,
|
||||
bool *got_output);
|
||||
|
||||
extern bool ffmpeg_decode_video(struct ffmpeg_decode *decode,
|
||||
uint8_t *data, size_t size, long long *ts,
|
||||
struct obs_source_frame2 *frame,
|
||||
bool *got_output);
|
||||
extern bool ffmpeg_decode_video(struct ffmpeg_decode *decode, uint8_t *data,
|
||||
size_t size, long long *ts,
|
||||
struct obs_source_frame2 *frame,
|
||||
bool *got_output);
|
||||
|
||||
static inline bool ffmpeg_decode_valid(struct ffmpeg_decode *decode)
|
||||
{
|
||||
|
Submodule plugins/win-dshow/libdshowcapture updated: 6226b35233...60a06c2da3
@@ -8,22 +8,21 @@ using namespace DShow;
|
||||
using namespace std;
|
||||
|
||||
struct DShowEncoder {
|
||||
obs_encoder_t *context;
|
||||
VideoEncoder encoder;
|
||||
obs_encoder_t *context;
|
||||
VideoEncoder encoder;
|
||||
|
||||
VideoEncoderConfig config;
|
||||
VideoEncoderConfig config;
|
||||
|
||||
const wchar_t *device;
|
||||
video_format format;
|
||||
long long frameInterval;
|
||||
const wchar_t *device;
|
||||
video_format format;
|
||||
long long frameInterval;
|
||||
|
||||
bool first = true;
|
||||
DARRAY(uint8_t) firstPacket;
|
||||
DARRAY(uint8_t) header;
|
||||
bool first = true;
|
||||
DARRAY(uint8_t) firstPacket;
|
||||
DARRAY(uint8_t) header;
|
||||
|
||||
inline DShowEncoder(obs_encoder_t *context_, const wchar_t *device_)
|
||||
: context(context_),
|
||||
device(device_)
|
||||
: context(context_), device(device_)
|
||||
{
|
||||
da_init(firstPacket);
|
||||
da_init(header);
|
||||
@@ -39,15 +38,16 @@ struct DShowEncoder {
|
||||
|
||||
inline bool Update(obs_data_t *settings);
|
||||
inline bool Encode(struct encoder_frame *frame,
|
||||
struct encoder_packet *packet, bool *received_packet);
|
||||
struct encoder_packet *packet,
|
||||
bool *received_packet);
|
||||
};
|
||||
|
||||
static const char *GetC985EncoderName(void*)
|
||||
static const char *GetC985EncoderName(void *)
|
||||
{
|
||||
return obs_module_text("Encoder.C985");
|
||||
}
|
||||
|
||||
static const char *GetC353EncoderName(void*)
|
||||
static const char *GetC353EncoderName(void *)
|
||||
{
|
||||
return obs_module_text("Encoder.C353");
|
||||
}
|
||||
@@ -85,10 +85,10 @@ inline bool DShowEncoder::Update(obs_data_t *settings)
|
||||
video_t *video = obs_encoder_video(context);
|
||||
const struct video_output_info *voi = video_output_get_info(video);
|
||||
|
||||
int bitrate = (int)obs_data_get_int(settings, "bitrate");
|
||||
int keyint_sec = (int)obs_data_get_int(settings, "keyint_sec");
|
||||
int width = (int)obs_encoder_get_width(context);
|
||||
int height = (int)obs_encoder_get_height(context);
|
||||
int bitrate = (int)obs_data_get_int(settings, "bitrate");
|
||||
int keyint_sec = (int)obs_data_get_int(settings, "keyint_sec");
|
||||
int width = (int)obs_encoder_get_width(context);
|
||||
int height = (int)obs_encoder_get_height(context);
|
||||
|
||||
double aspect = double(width) / double(height);
|
||||
|
||||
@@ -106,14 +106,14 @@ inline bool DShowEncoder::Update(obs_data_t *settings)
|
||||
|
||||
frameInterval = voi->fps_den * 10000000 / voi->fps_num;
|
||||
|
||||
config.fpsNumerator = voi->fps_num;
|
||||
config.fpsDenominator = voi->fps_den;
|
||||
config.bitrate = bitrate;
|
||||
config.keyframeInterval = keyint;
|
||||
config.cx = width;
|
||||
config.cy = height;
|
||||
config.name = id.name;
|
||||
config.path = id.path;
|
||||
config.fpsNumerator = voi->fps_num;
|
||||
config.fpsDenominator = voi->fps_den;
|
||||
config.bitrate = bitrate;
|
||||
config.keyframeInterval = keyint;
|
||||
config.cx = width;
|
||||
config.cy = height;
|
||||
config.name = id.name;
|
||||
config.path = id.path;
|
||||
|
||||
first = true;
|
||||
da_resize(firstPacket, 0);
|
||||
@@ -123,24 +123,22 @@ inline bool DShowEncoder::Update(obs_data_t *settings)
|
||||
|
||||
DStr encoder_name;
|
||||
dstr_from_wcs(encoder_name, config.name.c_str());
|
||||
blog(LOG_DEBUG, "win-dshow-encoder:\n"
|
||||
"\tencoder: %s\n"
|
||||
"\twidth: %d\n"
|
||||
"\theight: %d\n"
|
||||
"\tfps_num: %d\n"
|
||||
"\tfps_den: %d",
|
||||
deviceName->array,
|
||||
(int)width,
|
||||
(int)height,
|
||||
(int)voi->fps_num,
|
||||
(int)voi->fps_den);
|
||||
blog(LOG_DEBUG,
|
||||
"win-dshow-encoder:\n"
|
||||
"\tencoder: %s\n"
|
||||
"\twidth: %d\n"
|
||||
"\theight: %d\n"
|
||||
"\tfps_num: %d\n"
|
||||
"\tfps_den: %d",
|
||||
deviceName->array, (int)width, (int)height, (int)voi->fps_num,
|
||||
(int)voi->fps_den);
|
||||
|
||||
return encoder.SetConfig(config);
|
||||
}
|
||||
|
||||
static bool UpdateDShowEncoder(void *data, obs_data_t *settings)
|
||||
{
|
||||
DShowEncoder *encoder = reinterpret_cast<DShowEncoder*>(data);
|
||||
DShowEncoder *encoder = reinterpret_cast<DShowEncoder *>(data);
|
||||
|
||||
if (!obs_encoder_active(encoder->context))
|
||||
return encoder->Update(settings);
|
||||
@@ -149,7 +147,8 @@ static bool UpdateDShowEncoder(void *data, obs_data_t *settings)
|
||||
}
|
||||
|
||||
static inline void *CreateDShowEncoder(obs_data_t *settings,
|
||||
obs_encoder_t *context, const wchar_t *device)
|
||||
obs_encoder_t *context,
|
||||
const wchar_t *device)
|
||||
{
|
||||
DShowEncoder *encoder = nullptr;
|
||||
|
||||
@@ -159,7 +158,7 @@ static inline void *CreateDShowEncoder(obs_data_t *settings,
|
||||
|
||||
} catch (const char *error) {
|
||||
blog(LOG_ERROR, "Could not create DirectShow encoder '%s': %s",
|
||||
obs_encoder_get_name(context), error);
|
||||
obs_encoder_get_name(context), error);
|
||||
}
|
||||
|
||||
UNUSED_PARAMETER(settings);
|
||||
@@ -178,7 +177,7 @@ static void *CreateC353Encoder(obs_data_t *settings, obs_encoder_t *context)
|
||||
|
||||
static void DestroyDShowEncoder(void *data)
|
||||
{
|
||||
delete reinterpret_cast<DShowEncoder*>(data);
|
||||
delete reinterpret_cast<DShowEncoder *>(data);
|
||||
}
|
||||
|
||||
/* the first packet contains the SPS/PPS (header) NALs, so parse the first
|
||||
@@ -194,7 +193,8 @@ inline void DShowEncoder::ParseFirstPacket(const uint8_t *data, size_t size)
|
||||
while (nal_end != end) {
|
||||
nal_codestart = nal_start;
|
||||
|
||||
while (nal_start < end && !*(nal_start++));
|
||||
while (nal_start < end && !*(nal_start++))
|
||||
;
|
||||
|
||||
if (nal_start == end)
|
||||
break;
|
||||
@@ -207,11 +207,11 @@ inline void DShowEncoder::ParseFirstPacket(const uint8_t *data, size_t size)
|
||||
|
||||
if (type == OBS_NAL_SPS || type == OBS_NAL_PPS) {
|
||||
da_push_back_array(header, nal_codestart,
|
||||
nal_end - nal_codestart);
|
||||
nal_end - nal_codestart);
|
||||
|
||||
} else {
|
||||
da_push_back_array(firstPacket, nal_codestart,
|
||||
nal_end - nal_codestart);
|
||||
nal_end - nal_codestart);
|
||||
}
|
||||
|
||||
nal_start = nal_end;
|
||||
@@ -219,7 +219,8 @@ inline void DShowEncoder::ParseFirstPacket(const uint8_t *data, size_t size)
|
||||
}
|
||||
|
||||
inline bool DShowEncoder::Encode(struct encoder_frame *frame,
|
||||
struct encoder_packet *packet, bool *received_packet)
|
||||
struct encoder_packet *packet,
|
||||
bool *received_packet)
|
||||
{
|
||||
unsigned char *frame_data[DSHOW_MAX_PLANES] = {};
|
||||
size_t frame_sizes[DSHOW_MAX_PLANES] = {};
|
||||
@@ -238,18 +239,18 @@ inline bool DShowEncoder::Encode(struct encoder_frame *frame,
|
||||
|
||||
long long actualPTS = frame->pts * frameInterval;
|
||||
|
||||
bool success = encoder.Encode(frame_data, frame_sizes,
|
||||
actualPTS, actualPTS + frameInterval,
|
||||
dshowPacket, new_packet);
|
||||
bool success = encoder.Encode(frame_data, frame_sizes, actualPTS,
|
||||
actualPTS + frameInterval, dshowPacket,
|
||||
new_packet);
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
if (new_packet && !!dshowPacket.data && !!dshowPacket.size) {
|
||||
packet->data = dshowPacket.data;
|
||||
packet->size = dshowPacket.size;
|
||||
packet->type = OBS_ENCODER_VIDEO;
|
||||
packet->pts = dshowPacket.pts / frameInterval;
|
||||
packet->dts = dshowPacket.dts / frameInterval;
|
||||
packet->data = dshowPacket.data;
|
||||
packet->size = dshowPacket.size;
|
||||
packet->type = OBS_ENCODER_VIDEO;
|
||||
packet->pts = dshowPacket.pts / frameInterval;
|
||||
packet->dts = dshowPacket.dts / frameInterval;
|
||||
packet->keyframe = obs_avc_keyframe(packet->data, packet->size);
|
||||
|
||||
/* first packet must be parsed in order to retrieve header */
|
||||
@@ -267,15 +268,15 @@ inline bool DShowEncoder::Encode(struct encoder_frame *frame,
|
||||
}
|
||||
|
||||
static bool DShowEncode(void *data, struct encoder_frame *frame,
|
||||
struct encoder_packet *packet, bool *received_packet)
|
||||
struct encoder_packet *packet, bool *received_packet)
|
||||
{
|
||||
return reinterpret_cast<DShowEncoder*>(data)->Encode(frame, packet,
|
||||
received_packet);
|
||||
return reinterpret_cast<DShowEncoder *>(data)->Encode(frame, packet,
|
||||
received_packet);
|
||||
}
|
||||
|
||||
static bool GetDShowExtraData(void *data, uint8_t **extra_data, size_t *size)
|
||||
{
|
||||
DShowEncoder *encoder = reinterpret_cast<DShowEncoder*>(data);
|
||||
DShowEncoder *encoder = reinterpret_cast<DShowEncoder *>(data);
|
||||
|
||||
*extra_data = encoder->header.array;
|
||||
*size = encoder->header.num;
|
||||
@@ -286,22 +287,22 @@ static bool GetDShowExtraData(void *data, uint8_t **extra_data, size_t *size)
|
||||
static inline bool ValidResolution(uint32_t width, uint32_t height)
|
||||
{
|
||||
return (width == 1280 && height == 720) ||
|
||||
(width == 1024 && height == 768);
|
||||
(width == 1024 && height == 768);
|
||||
}
|
||||
|
||||
static void GetDShowVideoInfo(void *data, struct video_scale_info *info)
|
||||
{
|
||||
DShowEncoder *encoder = reinterpret_cast<DShowEncoder*>(data);
|
||||
DShowEncoder *encoder = reinterpret_cast<DShowEncoder *>(data);
|
||||
encoder->format = VIDEO_FORMAT_I420;
|
||||
|
||||
if (info->format == VIDEO_FORMAT_I420 &&
|
||||
ValidResolution(info->width, info->height))
|
||||
return;
|
||||
|
||||
info->format = VIDEO_FORMAT_I420;
|
||||
info->width = info->width;
|
||||
info->height = info->height;
|
||||
info->range = VIDEO_RANGE_DEFAULT;
|
||||
info->format = VIDEO_FORMAT_I420;
|
||||
info->width = info->width;
|
||||
info->height = info->height;
|
||||
info->range = VIDEO_RANGE_DEFAULT;
|
||||
info->colorspace = VIDEO_CS_DEFAULT;
|
||||
|
||||
double aspect = double(info->width) / double(info->height);
|
||||
@@ -325,7 +326,7 @@ static obs_properties_t *GetDShowEncoderProperties(void *data)
|
||||
obs_properties_t *ppts = obs_properties_create();
|
||||
|
||||
obs_properties_add_int(ppts, "bitrate", obs_module_text("Bitrate"),
|
||||
1000, 60000, 1);
|
||||
1000, 60000, 1);
|
||||
|
||||
UNUSED_PARAMETER(data);
|
||||
return ppts;
|
||||
@@ -333,16 +334,16 @@ static obs_properties_t *GetDShowEncoderProperties(void *data)
|
||||
|
||||
void RegisterDShowEncoders()
|
||||
{
|
||||
obs_encoder_info info = {};
|
||||
info.type = OBS_ENCODER_VIDEO;
|
||||
info.codec = "h264";
|
||||
info.destroy = DestroyDShowEncoder;
|
||||
info.encode = DShowEncode;
|
||||
info.update = UpdateDShowEncoder;
|
||||
info.get_defaults = GetDShowEncoderDefauts;
|
||||
info.get_properties = GetDShowEncoderProperties;
|
||||
info.get_extra_data = GetDShowExtraData;
|
||||
info.get_video_info = GetDShowVideoInfo;
|
||||
obs_encoder_info info = {};
|
||||
info.type = OBS_ENCODER_VIDEO;
|
||||
info.codec = "h264";
|
||||
info.destroy = DestroyDShowEncoder;
|
||||
info.encode = DShowEncode;
|
||||
info.update = UpdateDShowEncoder;
|
||||
info.get_defaults = GetDShowEncoderDefauts;
|
||||
info.get_properties = GetDShowEncoderProperties;
|
||||
info.get_extra_data = GetDShowExtraData;
|
||||
info.get_video_info = GetDShowVideoInfo;
|
||||
|
||||
vector<DeviceId> devices;
|
||||
DShow::VideoEncoder::EnumEncoders(devices);
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user