Skip to content

Commit b1e190c

Browse files
committed
nvdec: fix progressive_frame sometime incorrect
1 parent 3408008 commit b1e190c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎nvdec.zig‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ pub const Decoder = struct {
132132
frame_height: u32,
133133
surface_height: u32,
134134
output_format: nvdec_bindings.VideoSurfaceFormat,
135+
progressive_sequence: c_int,
135136
} = null,
136137

137138
error_state: ?Error = null,
@@ -327,12 +328,15 @@ pub const Decoder = struct {
327328
// surface height (chroma offset) is always 2-aligned
328329
.surface_height = @intCast(format.coded_height + (format.coded_height % 2)),
329330
.output_format = decoder_create_info.OutputFormat,
331+
.progressive_sequence = format.progressive_sequence,
330332
};
331333

332334
try self.context.push();
333335
try result(nvdec_bindings.cuvidCreateDecoder.?(&self.decoder, &decoder_create_info));
334336
try self.context.pop();
335337

338+
std.debug.print("{any}\n", .{decoder_create_info}); // TODO
339+
336340
return num_decode_surfaces;
337341
}
338342

@@ -341,6 +345,9 @@ pub const Decoder = struct {
341345
}
342346

343347
fn handle_display_picture(self: *Decoder, parser_disp_info: *nvdec_bindings.ParserDispInfo) !void {
348+
// Fix for https://forums.developer.nvidia.com/t/out-of-order-frames-from-nvdec/67779/5
349+
parser_disp_info.progressive_frame = self.format.progressive_sequence;
350+
344351
var proc_params = std.mem.zeroes(nvdec_bindings.ProcParams);
345352
proc_params.progressive_frame = parser_disp_info.progressive_frame;
346353
proc_params.second_field = parser_disp_info.repeat_first_field + 1;

0 commit comments

Comments
 (0)