Repository navigation
Conversation
defisym
force-pushed
the
codex/ffmpeg-android-jni
branch
from
October 31, 2026 17:03
5c63498 to
5164836
Compare
This was referenced Oct 31, 2026
defisym
force-pushed
the
codex/ffmpeg-android-jni
branch
from
November 4, 2026 03:36
5164836 to
a536208
Compare
defisym
force-pushed
the
codex/ffmpeg-android-jni
branch
from
November 4, 2026 03:40
a536208 to
a739240
Compare
Replace the GeneralDefinition umbrella with the existing arithmetic, string and code-page helpers. Remove a dead probe call-site comment. Keep the original helper contracts; do not introduce FFMpegUtilities or SDLAudioDefinition copies.
Use a standard exception constructor and fixed-width/standard integer types. Guard the D3D include on Windows and qualify Lock template references hidden by member names. Error flags and Windows public entry points are retained. Validate by compiling and decoding the first frame on a Linux host.
defisym
force-pushed
the
codex/ffmpeg-android-jni
branch
from
November 4, 2026 04:53
a739240 to
f97db56
Compare
Replace MemBuf with a non-owning, read-only MemView and allocate the AVIO working buffer independently with av_malloc. Free the current AVIO buffer explicitly, bound memory seeks and answer size queries. Let avformat probe through custom IO and remove the obsolete manual probe helper. Delegate constructors so partial initialization is destructed; keep the destructor adaptor guard because opening/probing/video-stream discovery can fail before the factory runs. Normal initialized players always have an adaptor, including software playback. Delegate the UTF-8 path overload to the existing wide-path constructor via the shared code-page conversion. Do not change forwardFrame packet unref behavior in this ownership commit. Host first-frame, memory-source playback/seek and failed-open checks pass.
defisym
force-pushed
the
codex/ffmpeg-android-jni
branch
from
November 4, 2026 05:32
f97db56 to
d3b1a78
Compare
Cache swscale by actual frame properties and allocate/report the output buffer and stride produced by FFmpeg. Expose the output format as an option while preserving the BGRA default and Windows row alignment. Host software-conversion stride/frame checks pass. Name the converted frame storage pConvertedFrameBuffer because callers may request BGRA, BGR24 or RGBA output.
defisym
force-pushed
the
codex/ffmpeg-android-jni
branch
2 times, most recently
from
November 4, 2026 06:13
e1636d7 to
d391071
Compare
Convert milliseconds using floating-point seconds and normalize decoded best-effort timestamps against the format start time. Avoid rounding a subsecond seek down to zero. Host fractional seek and frame-position checks pass. Cache the timeline origin once after avformat_find_stream_info succeeds, then reuse that per-player value for seek and frame-clock conversions. Read the initialized timelineOriginSeconds member directly in seek, video and audio conversions; remove the redundant getter.
Pass wt_stream_len instead of the remaining whole request to the mixer. Otherwise a request spanning PCM blocks mixes bytes beyond the current block and can mix the following region twice. Add a real SDL additive-mixing regression comparing a 100000-byte request with four-byte fragments. It fails immediately before this fix and passes afterward.
defisym
force-pushed
the
codex/ffmpeg-android-jni
branch
2 times, most recently
from
November 4, 2026 06:51
65e93fe to
e35e9e0
Compare
Preserve the original Send First branches, queue-wait early return, pending-packet retry and packet unref placement. Send the already computed nullable input pointer at EOF and keep the existing packet argument passed to receive wrappers. Use AVERROR_EOF for decoder completion and a nonnegative queue waiting state, keeping EIO/EPERM errors distinct. Propagate read failures and defer a source EAGAIN to the next video tick without spinning or reporting playback failure. Reset pending/finish state on seek. Audio timestamp and filter/resampler changes remain in the audio-pipeline commit; this commit keeps the original wrapper contract and timestamp placement. Add real FFmpeg-call regressions for Send First ordering, queue-wait early return without codec calls, source EAGAIN recovery, IO EIO and codec EPERM propagation. Shared playback/EOF, audio tails, delayed audio and memory-source regressions pass under ASan/UBSan.
defisym
force-pushed
the
codex/ffmpeg-android-jni
branch
2 times, most recently
from
November 4, 2026 07:27
44845e1 to
d2a04e7
Compare
defisym
commented
Nov 4, 2026
| set_audioTempo(ATEMPO_DEFAULT); | ||
| av_channel_layout_default(&targetChannelLayout, TARGET_CHANNEL_NUMBER); | ||
| av_channel_layout_default(&targetChannelLayout, TARGET_CHANNEL_NUMBER); | ||
| atempo = -1; // force the initial filter graph to be created |
Owner
Author
There was a problem hiding this comment.
在这里重置-1强制刷新,但是前面为什么赋初始值啊?!
defisym
commented
Nov 4, 2026
| #endif // AUDIO_TEMPO | ||
|
|
||
| float atempo = -1; | ||
| float atempo = ATEMPO_DEFAULT; |
defisym
commented
Nov 4, 2026
|
|
||
| //count++; | ||
| } | ||
| if (pFormatContext == this->pFormatContext |
Owner
Author
There was a problem hiding this comment.
这是用于快速跳转视频用于抓帧用的,所以音频包都丢掉了啊
defisym
force-pushed
the
codex/ffmpeg-android-jni
branch
from
November 5, 2026 13:29
d2a04e7 to
eb78c1e
Compare
Keep receive-frame, submit-filter, then collect-output ordering and KEEP_REF. Append all available PCM, send filter EOF once, drain the resampler and grow storage for accumulated samples. Reset DSP and buffered PCM on seek. Keep forwardFrame's frame-grabbing policy: discard audio packets without inserting them into the playback queue. Create the initial filter graph when absent and explicitly request rebuilds on seek, without assigning a sentinel tempo. Serialize the actual tempo so the filter and sample clock agree. Distinguish byte offsets from millisecond targets, including the negative-flags avformat_seek_file convention. Byte seeks disable time-based preroll trimming and anchor synchronization to the first valid decoded timestamp; independent preview contexts do not consume that pending main-playback anchor. Add standalone audio-seek regressions for native byte seeks, time seek units, default initialization, same-tempo seek after EOF, grab queue isolation and fractional tempo. The original c63af8f fails four targeted negative checks. The amended audio stage and all four later stages pass ASan/UBSan, as do the final existing PCM, decoder-protocol and shared-core regressions. Distinguish sample-clock startup from a valid timestamp anchor. If initial audio frames lack PTS, account for their input duration and accept the first later valid timestamp. Reset both states on seek. A wrapped real-decoder regression confirms byte-seek anchoring recovers without losing PCM; the previous revision fails this case.
Use monotonic time and the submitted PCM timeline, including delayed-audio silence. Keep decoder/filter lookahead out of the playback clock. Clamp interpolation to the actual submitted source-time span, including partial and empty callbacks at EOF or starvation, rather than the requested buffer size. Snapshot each callback's tempo so a later tempo change cannot retime PCM already submitted to the audio device. Preserve the remaining callback span across pause/resume. This remains a software estimate; device latency requires platform playback-position feedback. Retain set_pause(..., false) as a state-only update. Publish seek callbacks outside the audio lock so synchronized controls can reenter. Remove obsolete timer fields. Add deterministic clock regressions at 0.25x, 1x, 1.23x and 4x with 4/512/4096 byte callbacks, partial/empty EOF callbacks and tempo changes during a callback. The previous clocks revision fails the EOF-bound and tempo-continuity tests. All four affected stages and the existing final shared suite pass ASan/UBSan.
Move the existing Windows seek/preview flags and policy into the shared class, then call it from the Windows wrapper. Add unclocked preview, still-image handling and explicit playback/drain queries. Publish frame and seek callbacks after releasing the audio lock so control calls can reenter. Keep the existing Windows video-only loop policy. Add a standalone shared-core runner and regressions for seek, drain, AVIO, pause, Unicode paths and callback reentry; ASan/UBSan pass.
Add generic decoder-selection and context-lifetime hooks to the existing adaptor interface. Preserve explicit decoder overrides, accept delayed pixel-format discovery and retry software initialization after hardware setup fails. Keep the D3D implementation and guard its construction until a real device context exists. No Android adaptor is introduced here. The host core prefix compiles and its shared regressions pass; Windows MSBuild/device validation remains separate.
Add MediaCodec/GLES adaptors through the existing factories, thin JNI and Fusion Java bindings, and one shared SDL Mixer X transport for both plugins. Preserve application/file leases through native Fusion storage. Add platform SDK deployment and publishing using the Windows FFmpeg/OpenSSL version selectors. Use the existing shared conversion CMake interface and pinned iconv source/archives. Crypto calls the original Encryption core, with compatibility guarded only for Android 32-bit API 21-23; standalone Encrypter remains deferred. Include platform fixtures, reproduction/build notes and the recorded shared-core/recovery policies. The preceding commits contain the portable playback changes, grouped by intent. Host packaged-core CMake, SDK validation and ASan/UBSan shared-core checks pass; a new full Android export and Windows MSBuild remain for integration testing.
defisym
force-pushed
the
codex/ffmpeg-android-jni
branch
from
November 5, 2026 14:14
eb78c1e to
077893c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modifying existing stuff
Port FFMpeg and SDL_Mixer to Android through JNI while reusing the existing C++ playback/adaptor architecture and master's shared Encryption implementation. Clean up dependencies first, then review each shared-core problem separately; platform integration comes last.
The base remains master
36812170(portable encryption, #91). Already-merged encryption commits are not repeated. Commit author/committer identities remain associated withdefisym.Review order
Author review checkpoint — 2026-11-04: Items 1–7, through
4685fd99(Send First/read/error states), have been reviewed. Item 8,6dab60eb(audio pipeline), remains unreviewed. Item 9,1895bc01(clocks/controls), is currently being discussed; it and the following items are not marked approved. Resume substantive review at the audio-pipeline commit. Passing automated tests does not change this checkpoint.timelineOriginSecondsdirectly without a forwarding getter.The first eleven commits contain the C++ core and its focused tests/review notes. No Java, Android adaptor implementation or publishing hook appears in those commits. The final Android commit does not modify
FFMpeg.h; its shared playback changes are entirely visible in the preceding problem-specific commits.Cleanup and shared behavior
FFMpegUtilities.handSDLAudioDefinition.hare removed and never introduced anywhere in the rewritten history. FFMpeg directly includes the existing ArithmeticUtilities, StringUtilities and StringConversion helpers.SDLUtilities.hand its buffer constant remain exactly as on master; the unused FFMpeg alias disappears with the audio-pipeline fix.MemBufis replaced by a non-owningMemView: it stores a const source pointer and cursor, without allocating/freeing media or IO buffers.FFMpegseparately allocates the AVIO working buffer and frees its current pointer after FFmpeg probing may replace it. Memory playback/seek continue using native avformat probing. The UTF-8 constructor delegates to the existing wide-path constructor through the shared conversion helper.bRespond, immediateQUEUE_WAITINGreturn, pending-packet retry,pInputPacketpassed to receive wrappers, and packet unref placement. The decoder function's only semantic change against the original is using its already computed nullable input pointer for the EOF send. Source EAGAIN defers the video tick, completion uses nativeAVERROR_EOF, and nonnegative queue waiting remains distinct from EIO/EPERM. The FFMpeg.h diff in this commit is reduced to 10 added / 4 removed lines.KEEP_REF, filter-output loop and early codec/error returns. All available filtered blocks append to the existingaudio_bufbefore returning; codec EOF closes the filter once and drains filter/resampler tails. No separate output queue or pull-first scheduler is introduced. First-frame timing remains anchored before filter submission because filters may buffer input before producing output.goto_videoPositionstill locks the main context, flushes video/audio queues and the audio decoder, forwards to the target frame, then resets audio timing. Only the external display callback is deferred until after unlocking so synchronized controls can reenter. The image protections are retained: invalid frames do not invoke the copy callback, and single-image no-seek/no-revert policy is preserved in the following shared-policy commit.forwardFramereceive-EAGAINav_packet_unrefis withdrawn. The existing seek-loop packet-release behavior is retained. Its send-EAGAIN retry issue is not claimed resolved by the separate queued-playback decoder fix.DeLib::Helpersmodule and FTW's pinned iconv dependency, including matching source/notices. There is no second string-conversion implementation or separately selected iconv version.pConvertedFrameBufferto cover the requested pixel formats; the rename is folded into the software-conversion commit.Extensions/FFMpeg/tests, independently of JNI/Android; the Android runner calls those same sources. The review ledger is in tests/README.md.Audio review corrections — 2026-11-05
Folded into
6dab60eb; the first seven reviewed commits through4685fd99are unchanged. The later four commits are replayed, and the audio commit remains awaiting author review.forwardFrame's frame-grabbing behavior: discard encountered audio packets; do not enqueue them into the main playback queue.atempo = -1.avformat_seek_fileconvention before interpreting byte versus time units.Run
Extensions/FFMpeg/tests/run_audio_seek.pywith the same four FFmpeg/SDL include/library options as the existing shared runner. It generates real MP4/MPEG-TS fixtures and tests byte/time seeks, EOF restart, default graph construction, grab queue isolation and fractional tempo. Optional--baseline-includeaccepts a directory containing the originalc63af8fdheader for negative checks.The amended audio stage and all four later stages pass these ASan/UBSan tests. The original audio commit fails all four targeted negative checks (seek units, byte-seek PCM, grab queue isolation and tempo). The final existing PCMFragmentTest, DecoderProtocolTest and SharedCoreTest also pass. Tests used host FFmpeg 7.1.5 and SDL2; no Windows/Android build or device playback was performed for this correction. Across the audio-review corrections, changes relative to the original
d2a04e75head are limited toFFMpeg.hand four audio regression files.The follow-up review is split by responsibility:
6dab60eb: distinguish sample-clock startup from a valid timestamp anchor. After missing initial audio PTS, use the first later valid timestamp and account for the preceding input duration; reset this state on seek. The newlate-ptstest fails on the previous5d903e6frevision and passes after the correction.1895bc01: estimate playback from submitted PCM, clamp to the actual submitted span (including partial/empty callbacks), and snapshot the callback tempo so changing speed cannot retime already submitted PCM. Pause/resume preserves the remaining submitted span.run_audio_clock.pytakes the same four include/library options as the other host runners. Its deterministic clock tests cover 0.25x/1x/1.23x/4x, 4/512/4096-byte callbacks, EOF tails, empty callbacks and tempo/pause continuity. Optional--baseline-includeconfirms the previous clocks revision fails the EOF-bound and tempo-continuity cases. The test compiler exposes the internal estimator with-fno-access-control; production headers gain no test hooks.Platform boundaries and dependencies
Android compiles the original
FFMpegclass and established adaptor factories. MediaCodec Surface output and GLES copies use platform adaptors beside D3D. Java retains actual Fusion runtime, renderer, storage and file access. Portable playback state, scheduling, queues, seek and clocks remain in C++.Both plugins use one SDL Mixer X device: FFmpeg's original PCM callback supplies independent looping-chunk/effect channels while SDL_Mixer retains music streams. FFmpeg tempo uses the shared libavfilter chain.
FFmpeg Android deployment reads Windows'
FFmpegVersion.cmake; crypto deployment readsEncryptVersion.cmakeand its pinned OpenSSL/vcpkg selection. Android SDK version/source/API/ABI checks reject stale inputs. Both exports ship the same shared audio/crypto runtime and matching bindings/source payloads.MediaCrypto JNI calls the original Encryption C API, explicitly selecting legacy Win32 seed width for password compatibility. File resolution/materialization/cache leases remain in native Fusion application storage. The FileSource compatibility branch is restricted to Android 32-bit API 21–23; other platform/API paths remain unchanged. The standalone Encrypter Fusion extension is still deferred.
Validation for this cleanup and history rewrite
decode_apacketchanges in the final tree; the correction is folded into the audio-pipeline commit, preserving the first seven commits and keeping Android last.git diff --check. The later format-neutral buffer rename and removal of the redundant timeline-origin getter passed syntax-only C++ compilation. The initialization-time timeline-origin cache passed the shared ASan/UBSan regressions and a before/after seek comparison on a video starting at 7 seconds (relative 1500 ms seeks map to source 8.5 seconds in both versions).The current core prefixes from the changed ownership commit onward, the expanded ASan/UBSan regressions and the packaged-core CMake build were rerun after the MemView review changes. A focused negative check also confirms that removing the destructor adaptor guard crashes on missing-input construction.
Earlier integration validation is recorded in the Android READMEs: four-ABI native/crypto builds, JNI reference/ACE/lifecycle fixtures, encryption interoperability and the independent Android playback probe. Those results were obtained before this cleanup. This rewrite has not rerun a complete Android export/NDK build, Windows MSBuild or physical-device playback; the new common-helper/iconv linkage still needs those integration builds.
Open review finding: single-image preview
A host comparison before the clocks commit, at the clocks commit, and at current HEAD found the same PNG preview limitation with automatic/2-thread decoding:
forwardFramereceives EAGAIN on its single packet, then reaches demux EOF without draining delayed codec output, producing no first-frame callback. This predates the clocks commit and remains unresolved; it is not a deletion of the queue/timing safeguards. Single-thread PNG and JPEG at 1/2/automatic threads render one valid frame without a black replacement; current shared-policy repeated seek/playback calls preserve it. These are host software-decoding ASan/UBSan checks, not Windows/Fusion/device-renderer validation. Track codec EOF draining inforwardFrameseparately without reopening already-reviewed core commits.Build and user testing
See the combined build/file/encryption guide and each extension's
Android/README.md. Rebuild/install both ZIPs from the same revision and shared SDK caches.Opening, seeking, video decoding and materialization remain synchronous on the Fusion calling thread. Native Windows pointer/cSurface expressions retain their documented Android empty/0 behavior.