ffmpeg_bridge: fix cross-platform CI failures (Ubuntu/macOS/Windows)
Ubuntu (FFmpeg 7.0) build failure: the public FB_PIX_FMT_* values were hardcoded to AVPixelFormat enum values, but those shift between FFmpeg releases (new formats are inserted mid-enum: X2RGB10 in 7.0, RGBF16/GRAYF16 later), so the static_asserts in internal.h failed and RGBF16LE/GRAYF16LE did not exist at all. The FB pixel format values are now fixed identifiers translated inside the library by pixel format name (stable across releases): - fb::PixFmtToAV/PixFmtFromAV resolve the static table by name; formats a decoder produces that have no static identifier (hardware downloads like nv12/p010le/p210le) receive process-local dynamic ids >= 1000 so they keep round-tripping through the API (scaler etc.) instead of collapsing to NONE and crashing sws. - All crossing points translated: scaler, frame get/set format, decoder/probe stream info, encoder config and write_video_frame, fb_pix_fmt_* utilities, fb_find_best_pix_fmt_of_list (which also reinterpret_cast the caller's list; now translated element-wise and properly NONE-terminated). - nv12 and p010le get static identifiers as the common hardware download formats. - Hardware frame detection no longer compares pixel formats (breaks across format spaces); it uses the existing fb_frame_is_hw(). macOS test failures (FFmpegBridgeEncoder.WritePngVideoAndProbeBack, WritePcmAudioAndProbeBack): config.filename held a dangling pointer to a temporary QByteArray (UB; happened to work on Linux). Keep the QByteArray alive for the encoder's lifetime. Windows (MSYS2 UCRT64) build failure: timecodefunctions.h used int64_t without including <cstdint> (previously pulled in transitively). Full gtest suite: 584 passed.
This commit is contained in:
@@ -431,7 +431,7 @@ int fb_decoder_get_stream_info(const FBDecoder *decoder, FBStreamInfo *out)
|
||||
out->has_decoder = 1; // stream is open, so a decoder was found
|
||||
out->width = par->width;
|
||||
out->height = par->height;
|
||||
out->pixel_format = par->format;
|
||||
out->pixel_format = fb::PixFmtFromAV(AVPixelFormat(par->format));
|
||||
out->field_order = decoder->codec_ctx ? decoder->codec_ctx->field_order :
|
||||
AV_FIELD_UNKNOWN;
|
||||
out->color_range = par->color_range;
|
||||
@@ -499,5 +499,8 @@ int fb_decoder_hwaccel_enabled(const FBDecoder *decoder)
|
||||
|
||||
int fb_decoder_hw_pix_fmt(const FBDecoder *decoder)
|
||||
{
|
||||
return decoder ? int(decoder->hw_pix_fmt) : FB_PIX_FMT_NONE;
|
||||
// Hardware pixel formats have no static FB_PIX_FMT_* identifier, so this
|
||||
// returns a process-local dynamic id for them. Use fb_frame_is_hw() to
|
||||
// detect hardware frames.
|
||||
return decoder ? fb::PixFmtFromAV(decoder->hw_pix_fmt) : FB_PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user