Bug 1766646 - Vendor libwebrtc from 41a111d5b9

Upstream commit: https://webrtc.googlesource.com/src/+/41a111d5b944d48fcb1fbdcbf08622624b5750f7
    Switch to av_packet_alloc()

    ffmpeg is going to be hiding the implementation of AVPacket, so we can't
    allocate them on the stack anymore. av_init_packet is marked deprecated
    on TOT ffmpeg, so remove its use everywhere in favor of av_packet_alloc
    and av_packet_free.

    Bug: chromium:1211508
    Change-Id: I154311071123110dd749c71dec1ec2a0452b3908
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217780
    Commit-Queue: Ted Meyer <tmathmeyer@google.com>
    Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
    Cr-Commit-Position: refs/heads/master@{#34106}
This commit is contained in:
Michael Froman 2022-05-26 12:04:59 -05:00 коммит произвёл Connor Sheehan
Родитель 9cff45edf5
Коммит 8402df83ad
3 изменённых файлов: 25 добавлений и 6 удалений

3
third_party/libwebrtc/README.moz-ff-commit поставляемый
Просмотреть файл

@ -5856,3 +5856,6 @@ ae0d117d51
# MOZ_LIBWEBRTC_SRC=/home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src MOZ_LIBWEBRTC_COMMIT=mjfdev bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
0f506780aa
# MOZ_LIBWEBRTC_SRC=/home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src MOZ_LIBWEBRTC_COMMIT=mjfdev bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
41a111d5b9

2
third_party/libwebrtc/README.mozilla поставляемый
Просмотреть файл

@ -3906,3 +3906,5 @@ libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwe
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-05-26T16:48:48.280531.
# python3 vendor-libwebrtc.py --from-local /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src --commit mjfdev libwebrtc
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-05-26T17:01:43.999257.
# python3 vendor-libwebrtc.py --from-local /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src --commit mjfdev libwebrtc
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-05-26T17:04:54.294085.

Просмотреть файл

@ -54,6 +54,16 @@ enum H264DecoderImplEvent {
kH264DecoderEventMax = 16,
};
struct ScopedPtrAVFreePacket {
void operator()(AVPacket* packet) { av_packet_free(&packet); }
};
typedef std::unique_ptr<AVPacket, ScopedPtrAVFreePacket> ScopedAVPacket;
ScopedAVPacket MakeScopedAVPacket() {
ScopedAVPacket packet(av_packet_alloc());
return packet;
}
} // namespace
int H264DecoderImpl::AVGetBuffer2(AVCodecContext* context,
@ -202,7 +212,7 @@ int32_t H264DecoderImpl::InitDecode(const VideoCodec* codec_settings,
// a pointer |this|.
av_context_->opaque = this;
AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
if (!codec) {
// This is an indication that FFmpeg has not been initialized or it has not
// been compiled/initialized with the correct set of codecs.
@ -261,21 +271,25 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image,
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
AVPacket packet;
av_init_packet(&packet);
ScopedAVPacket packet = MakeScopedAVPacket();
if (!packet) {
ReportError();
return WEBRTC_VIDEO_CODEC_ERROR;
}
// packet.data has a non-const type, but isn't modified by
// avcodec_send_packet.
packet.data = const_cast<uint8_t*>(input_image.data());
packet->data = const_cast<uint8_t*>(input_image.data());
if (input_image.size() >
static_cast<size_t>(std::numeric_limits<int>::max())) {
ReportError();
return WEBRTC_VIDEO_CODEC_ERROR;
}
packet.size = static_cast<int>(input_image.size());
packet->size = static_cast<int>(input_image.size());
int64_t frame_timestamp_us = input_image.ntp_time_ms_ * 1000; // ms -> μs
av_context_->reordered_opaque = frame_timestamp_us;
int result = avcodec_send_packet(av_context_.get(), &packet);
int result = avcodec_send_packet(av_context_.get(), packet.get());
if (result < 0) {
RTC_LOG(LS_ERROR) << "avcodec_send_packet error: " << result;
ReportError();