obs-studio/plugins/win-dshow/ffmpeg-decode.h
jp9000 32f60d07a3 win-dshow: Add LGP timestamp fix
LGP devices are devices that induce anger in any sane developer because
they're prone to bad audio timestamps when using their decoded data
directly.  For that reason, add a hack that smooths the timestamps
within a large threshold to prevent audio skipping.
2017-02-22 01:18:24 -08:00

76 lines
2.1 KiB
C

/******************************************************************************
Copyright (C) 2014 by Hugh Bailey <obs.jim@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <obs.h>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4244)
#pragma warning(disable : 4204)
#endif
#include <libavcodec/avcodec.h>
#include <libavutil/log.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
struct ffmpeg_decode {
AVCodecContext *decoder;
AVCodec *codec;
AVFrame *frame;
uint8_t *packet_buffer;
size_t packet_size;
uint64_t lgp_start_ts;
uint64_t lgp_frames_since_start;
uint64_t lgp_next_expected_ts;
bool lgp_started;
bool fix_braindead_lgp_audio_packet_stupidity;
};
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,
uint8_t *data, size_t size, long long *ts,
struct obs_source_audio *audio,
bool *got_output);
extern int ffmpeg_decode_video(struct ffmpeg_decode *decode,
uint8_t *data, size_t size, long long *ts,
struct obs_source_frame *frame,
bool *got_output);
static inline bool ffmpeg_decode_valid(struct ffmpeg_decode *decode)
{
return decode->decoder != NULL;
}
#ifdef __cplusplus
}
#endif