AvPlayer: fix Crash Bandicoot 4 intro playback and green video padding (#848)

* AvPlayer: advance the shared audio-master clock after final audio frame

* AvPlayer: initialize padded NV12 planes with neutral black

---------

Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
Devran Cosmo Uenal
2026-09-26 18:39:46 +02:00
committed by GitHub
parent 16b83a034c
commit e0b682e4b2
+8 -8
View File
@@ -950,9 +950,6 @@ public:
if (deliver_seek_frame || sync_mode != 0) { if (deliver_seek_frame || sync_mode != 0) {
return true; return true;
} }
if (audio_id) {
return candidate.info.time_stamp <= last_audio_ts;
}
auto now = CurrentTimeNoLock(); auto now = CurrentTimeNoLock();
return now == 0 || candidate.info.time_stamp <= now; return now == 0 || candidate.info.time_stamp <= now;
}); });
@@ -999,7 +996,9 @@ public:
out->details.audio.size = current_audio->info.details.audio.size; out->details.audio.size = current_audio->info.details.audio.size;
std::memcpy(out->details.audio.language_code, std::memcpy(out->details.audio.language_code,
current_audio->info.details.audio.language_code, 4); current_audio->info.details.audio.language_code, 4);
last_audio_ts = out->time_stamp; start_time_ms = out->time_stamp;
clock_start = std::chrono::steady_clock::now();
paused_extra = {};
RecordLoopBoundary(*current_audio); RecordLoopBoundary(*current_audio);
return true; return true;
} }
@@ -1064,7 +1063,6 @@ private:
video_done = true; video_done = true;
audio_done = true; audio_done = true;
seek_video_frame_pending = false; seek_video_frame_pending = false;
last_audio_ts = 0;
last_output_loop_offset = 0; last_output_loop_offset = 0;
pending_loop_warnings = 0; pending_loop_warnings = 0;
} }
@@ -1541,11 +1539,14 @@ private:
return false; return false;
} }
auto* dst = buffer->Get(); auto* dst = buffer->Get();
std::memset(dst, 0, static_cast<size_t>(size)); auto* c = dst + pitch * h;
// PPSA02433 samples the padded columns; zero chroma would turn them green.
std::memset(dst, s->codecpar->color_range == AVCOL_RANGE_JPEG ? 0 : 16,
static_cast<size_t>(pitch) * h);
std::memset(c, 128, static_cast<size_t>(pitch) * h / 2);
for (int y = 0; y < src->height; y++) { for (int y = 0; y < src->height; y++) {
std::memcpy(dst + y * pitch, nv12->data[0] + y * nv12->linesize[0], src->width); std::memcpy(dst + y * pitch, nv12->data[0] + y * nv12->linesize[0], src->width);
} }
auto* c = dst + pitch * h;
for (int y = 0; y < src->height / 2; y++) { for (int y = 0; y < src->height / 2; y++) {
std::memcpy(c + y * pitch, nv12->data[1] + y * nv12->linesize[1], src->width); std::memcpy(c + y * pitch, nv12->data[1] + y * nv12->linesize[1], src->width);
} }
@@ -1674,7 +1675,6 @@ private:
int32_t trick_speed = AVPLAYER_TRICK_SPEED_NORMAL; int32_t trick_speed = AVPLAYER_TRICK_SPEED_NORMAL;
uint32_t sync_mode = 0; uint32_t sync_mode = 0;
uint64_t start_time_ms = 0; uint64_t start_time_ms = 0;
uint64_t last_audio_ts = 0;
uint64_t last_output_loop_offset = 0; uint64_t last_output_loop_offset = 0;
uint32_t pending_loop_warnings = 0; uint32_t pending_loop_warnings = 0;
std::chrono::steady_clock::time_point clock_start {}; std::chrono::steady_clock::time_point clock_start {};