Repository navigation
fix: use real MJPG decoded size instead of negotiated resolution - #529
Merged
deepin-bot[bot] merged 1 commit intoOct 12, 2026
Merged
Conversation
Do not preset decoder width/height before avcodec_open2(); let FFmpeg parse the real size from the JPEG SOF header. Copy decoded frames using the actual sw_frame/picture dimensions and realloc buffers when needed. Add jpeg_get_decoded_size() and trim yuv_frame to the real decoded size. 不在 avcodec_open2() 前预设解码器宽高,改由 FFmpeg 从 JPEG SOF 头解析 真实尺寸。按实际解码帧尺寸拷贝并在需要时 realloc 缓冲。新增 jpeg_get_decoded_size(),并在首帧后将 yuv_frame 收紧到真实解码尺寸。 Log: 修复MJPG解码尺寸与协商分辨率不一致导致的解码失败和画面错位 PMS: BUG-372317 Influence: 修复相机协商与实际分辨率不一致导致的解码失败、画面错位及内存浪费。
Reviewer's GuideMJPG decoding now lets FFmpeg parse the JPEG SOF dimensions, copies frames using the actual decoded geometry, and propagates that geometry to V4L2 frames while resizing buffers to avoid decode failures, image misalignment, and unnecessary memory usage when negotiated and encoded resolutions differ. Sequence diagram for MJPG decoding with actual JPEG dimensionssequenceDiagram
participant V4L2 as V4L2 frame decoder
participant JPEG as JPEG decoder
participant FFmpeg
participant Frame as yuv_frame buffer
V4L2->>JPEG: jpeg_decode(out_buf, in_buf, size)
JPEG->>FFmpeg: Decode JPEG without preset width/height
FFmpeg-->>JPEG: Decoded frame with width, height, format
JPEG->>Frame: av_image_copy_to_buffer(actual width, actual height)
JPEG-->>V4L2: Decode result
V4L2->>JPEG: jpeg_get_decoded_size(real_w, real_h)
JPEG-->>V4L2: Return decoded dimensions
alt negotiated size differs
V4L2->>V4L2: Update frame width and height
end
alt buffer size differs
V4L2->>Frame: realloc(actual width * actual height * 3 / 2)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
lzwind
approved these changes
Oct 12, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
deepin-bot
Bot
merged commit Oct 12, 2026
e0bd925
into
linuxdeepin:release/eagle
16 of 17 checks passed
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.
fix: use real MJPG decoded size instead of negotiated resolution
Do not preset decoder width/height before avcodec_open2(); let FFmpeg
parse the real size from the JPEG SOF header. Copy decoded frames using
the actual sw_frame/picture dimensions and realloc buffers when needed.
Add jpeg_get_decoded_size() and trim yuv_frame to the real decoded size.
不在 avcodec_open2() 前预设解码器宽高,改由 FFmpeg 从 JPEG SOF 头解析
真实尺寸。按实际解码帧尺寸拷贝并在需要时 realloc 缓冲。新增
jpeg_get_decoded_size(),并在首帧后将 yuv_frame 收紧到真实解码尺寸。
Log: 修复MJPG解码尺寸与协商分辨率不一致导致的解码失败和画面错位
PMS: BUG-372317
Influence: 修复相机协商与实际分辨率不一致导致的解码失败、画面错位及内存浪费。
Summary by Sourcery
Use JPEG-decoded dimensions throughout MJPG processing to correctly handle cameras whose actual frame size differs from the negotiated resolution.
Bug Fixes:
Enhancements: