mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-11 01:27:33 +00:00
Force libvpx_vp9 decoder for VP9 videos.
Webm stickers depend on decoder support for alpha channel.
This commit is contained in:
parent
545392f90f
commit
91c84d63de
@ -154,6 +154,13 @@ void FormatDeleter::operator()(AVFormatContext *value) {
|
||||
}
|
||||
}
|
||||
|
||||
AVCodec *FindDecoder(not_null<AVCodecContext*> context) {
|
||||
// Force libvpx-vp9, because we need alpha channel support.
|
||||
return (context->codec_id == AV_CODEC_ID_VP9)
|
||||
? avcodec_find_decoder_by_name("libvpx-vp9")
|
||||
: avcodec_find_decoder(context->codec_id);
|
||||
}
|
||||
|
||||
CodecPointer MakeCodecPointer(not_null<AVStream*> stream) {
|
||||
auto error = AvErrorWrap();
|
||||
|
||||
@ -172,7 +179,7 @@ CodecPointer MakeCodecPointer(not_null<AVStream*> stream) {
|
||||
av_opt_set(context, "threads", "auto", 0);
|
||||
av_opt_set_int(context, "refcounted_frames", 1, 0);
|
||||
|
||||
const auto codec = avcodec_find_decoder(context->codec_id);
|
||||
const auto codec = FindDecoder(context);
|
||||
if (!codec) {
|
||||
LogError(qstr("avcodec_find_decoder"), context->codec_id);
|
||||
return {};
|
||||
|
@ -158,6 +158,7 @@ using SwscalePointer = std::unique_ptr<SwsContext, SwscaleDeleter>;
|
||||
void LogError(QLatin1String method);
|
||||
void LogError(QLatin1String method, FFmpeg::AvErrorWrap error);
|
||||
|
||||
[[nodiscard]] AVCodec *FindDecoder(not_null<AVCodecContext*> context);
|
||||
[[nodiscard]] crl::time PtsToTime(int64_t pts, AVRational timeBase);
|
||||
// Used for full duration conversion.
|
||||
[[nodiscard]] crl::time PtsToTimeCeil(int64_t pts, AVRational timeBase);
|
||||
|
@ -327,8 +327,7 @@ bool FFMpegReaderImplementation::start(Mode mode, crl::time &positionMs) {
|
||||
_codecContext->pkt_timebase = _fmtContext->streams[_streamId]->time_base;
|
||||
av_opt_set_int(_codecContext, "refcounted_frames", 1, 0);
|
||||
|
||||
const auto codec = avcodec_find_decoder(_codecContext->codec_id);
|
||||
|
||||
const auto codec = FFmpeg::FindDecoder(_codecContext);
|
||||
if (_mode == Mode::Inspecting) {
|
||||
const auto audioStreamId = av_find_best_stream(_fmtContext, AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0);
|
||||
_hasAudioStream = (audioStreamId >= 0);
|
||||
|
Loading…
Reference in New Issue
Block a user