Skip to content

Commit 6f84883

Browse files
authored
Merge pull request #208 from shiguredo/feature/fix-amd-amf-autoscaling
AMF がオートスケール時に正しく動作しないのを修正する
2 parents b46f512 + 561d96b commit 6f84883

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
- @melpon
5353
- [ADD] インストールするファイルに cmake/android.toolchain.cmake を追加
5454
- @melpon
55+
- [FIX] AMD AMF のデコーダーがオートスケーリング時に映像がおかしくなるのを修正
56+
- @melpon
5557

5658
### misc
5759

examples/sumomo/src/sumomo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ class Sumomo : public std::enable_shared_from_this<Sumomo>,
233233
void OnPush(std::string text) override {}
234234
void OnMessage(std::string label, std::string data) override {}
235235

236-
void OnTrack(webrtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver)
237-
override {
236+
void OnTrack(webrtc::scoped_refptr<webrtc::RtpTransceiverInterface>
237+
transceiver) override {
238238
if (renderer_ == nullptr) {
239239
return;
240240
}
@@ -591,6 +591,7 @@ int main(int argc, char* argv[]) {
591591
if (!audio_playout_device.empty()) {
592592
context_config.audio_playout_device = audio_playout_device;
593593
}
594+
context_config.use_audio_device = false;
594595
context_config.video_codec_factory_config.preference = std::invoke([&]() {
595596
std::optional<sora::VideoCodecPreference> preference;
596597
auto add_codec_preference =

src/hwenc_amf/amf_video_decoder.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ int32_t AMFVideoDecoderImpl::Decode(const webrtc::EncodedImage& input_image,
155155
// queue is full; sleep, try to get ready surfaces in polling thread and repeat submission
156156
amf_sleep(1);
157157
continue;
158+
} else if (res == AMF_RESOLUTION_CHANGED || res == AMF_RESOLUTION_UPDATED) {
159+
// デコードするサイズが変わったらデコーダを作り直す
160+
ReleaseAMF();
161+
InitAMF();
162+
continue;
158163
} else {
159164
RETURN_IF_FAILED(res, L"Failed to SubmitInput()");
160165
break;
@@ -182,12 +187,17 @@ AMF_RESULT AMFVideoDecoderImpl::ProcessSurface(amf::AMFSurfacePtr surface) {
182187
RETURN_IF_FAILED(res, "Failed to Convert()");
183188

184189
uint32_t pts = surface->GetPts();
185-
RTC_LOG(LS_ERROR) << "pts=" << pts;
186190

187191
auto py = surface->GetPlane(amf::AMF_PLANE_Y);
188192
auto pu = surface->GetPlane(amf::AMF_PLANE_U);
189193
auto pv = surface->GetPlane(amf::AMF_PLANE_V);
190194

195+
// RTC_LOG(LS_ERROR) << "AMFVideoDecoderImpl::ProcessSurface: "
196+
// << "pts=" << pts << ", width=" << py->GetWidth()
197+
// << ", height=" << py->GetHeight()
198+
// << ", pitch_y=" << py->GetHPitch()
199+
// << ", pitch_u=" << pu->GetHPitch()
200+
// << ", pitch_v=" << pv->GetHPitch();
191201
webrtc::scoped_refptr<webrtc::I420Buffer> i420_buffer =
192202
buffer_pool_.CreateI420Buffer(py->GetWidth(), py->GetHeight());
193203
libyuv::I420Copy((const uint8_t*)py->GetNative(), py->GetHPitch(),

0 commit comments

Comments
 (0)