FMV: Allow up to 17 frames in picture FIFO

- Fixes long videos with small frame size
- Fixes videos in "Les Guignols de l’Info"

A user has mentioned that "Les Guignols de l’Info" sometimes has problems with videos.

After analysis of "/cd/rtf/application.rtf" from said disc,
starting at byte position 0x11DEA000, it turns out that the
pictures in FIFO (0x0E040A4) can go up to 17 even on real hardware.
This has never happened before and I've assumed that 8 is the maximum.

This is an issue because DecodTS of fdrvs1 calculates the DTS of the next picture with
the formula GEN_DEC_TIM1 (0x0E040A0) - GEN_PINF (0x0E040A4) * GEN_PICT_RATE (0x0E040A8).
This means that GEN_DEC_TIM1 is constantly increasing but GEN_PINF was limited to 8
before. This resulted in having the next picture to show getting more and more out of reach
of V_SCR.

On real hardware, the FIFO reaches 14 until playback starts.
This commit is contained in:
Andre Zeps
2026-01-02 17:11:46 +01:00
parent fd68fef278
commit b8e3baca21
10 changed files with 241 additions and 250 deletions

7
CDi.sv
View File

@@ -585,7 +585,7 @@ module emu (
`ifdef VERILATOR
// DDR3 simulation
bit [63:0] ddram[5000000/8] /*verilator public_flat_rd*/;
bit [63:0] ddram[16777216/8] /*verilator public_flat_rd*/;
int ddr_latencycnt;
bit [7:0] ddr_words_to_prove;
@@ -605,7 +605,8 @@ module emu (
DDRAM_DOUT_READY <= 0;
if (DDRAM_WE && !DDRAM_BUSY) begin
ddram[DDRAM_ADDR[19:0]] <= DDRAM_DIN;
assert (DDRAM_ADDR[21] == 0);
ddram[DDRAM_ADDR[20:0]] <= DDRAM_DIN;
//$display("Write at %x %x",DDRAM_ADDR, DDRAM_DIN);
end
@@ -619,7 +620,7 @@ module emu (
if (DDRAM_BUSY) begin
if (ddr_latencycnt > 0) ddr_latencycnt <= ddr_latencycnt - 1;
else begin
DDRAM_DOUT <= ddram[ddr_addr[19:0]];
DDRAM_DOUT <= ddram[ddr_addr[20:0]];
ddr_addr <= ddr_addr + 1;
DDRAM_DOUT_READY <= 1;
ddr_words_to_prove <= ddr_words_to_prove - 1;

View File

@@ -24,7 +24,7 @@ module decoder_firmware_memory #(
output [DATA_WIDTH_R-1:0] data_out1,
output [DATA_WIDTH_R-1:0] data_out2
);
localparam RAM_DEPTH = 13000 >> 2;
localparam RAM_DEPTH = 13070 >> 2;
// model the RAM with two dimensional packed array
logic [BYTES-1:0][BYTE_WIDTH-1:0] ram[0:RAM_DEPTH-1];

View File

@@ -1,16 +1,16 @@
00003117
0b010113
2d010113
00003517
84050513
82c50513
00003597
deb58593
00758593
00b50763
00052023
4de30511
10effeb5
a0010bf0
a703678d
1101df07
110100c7
c64ec84a
cc22ce06
89aaca26
@@ -29,11 +29,11 @@ cb15892e
00230731
640d00d7
05134485
4651dc84
a8234581
10efde97
051331f0
40f2dc84
4651fe44
a6234581
10ef0097
051330b0
40f2fe44
20234462
22230125
26230125
@@ -70,14 +70,14 @@ fcf513e3
100037b7
0067ae23
678d8082
dfc78793
01878793
579453d0
01c7af03
0207ae03
02d60333
0087a283
00c7af83
56052a23
7a052223
08052023
08c52223
08c52823
@@ -122,7 +122,7 @@ dfc78793
242310d5
079310b5
05131185
08335785
08337a85
05b301d7
cb980067
0057a023
@@ -161,7 +161,7 @@ f8e38f95
47311000
479cc798
0813680d
2423dfc8
24230188
273700f8
431c1000
45ad4354
@@ -234,7 +234,7 @@ fed788e3
c71c4785
8c63471c
65091207
77c50513
76850513
04050313
3637459d
4e211000
@@ -261,7 +261,7 @@ fed789e3
c71c4785
cbc5471c
05136509
031377c5
03137685
459d0405
10003637
48834e21
@@ -291,7 +291,7 @@ d6934047
222300d8
2c230268
24230118
47cd02a8
47f502a8
00b7d463
0a082623
100027b7
@@ -305,28 +305,28 @@ cb884505
471401c7
6589bf19
8593650d
05136fc5
0613e685
05136e85
06130845
10ef0400
678d7aa0
dfc78813
678d7960
01878813
6589bf8d
8593650d
051373c5
0613e285
05137285
06130445
10ef0400
678d78e0
dfc78813
678d77a0
01878813
1101b5f5
648dca26
c84acc22
892ac64e
841389ae
85138484
06138484
45815800
85138344
06138344
45817b00
10efce06
24236860
24236720
22230734
27b70724
4b981000
@@ -351,7 +351,7 @@ fea690e3
078ec408
10002737
8513c35c
31458484
31458344
100027b7
eb9d4b9c
852240f2
@@ -365,9 +365,9 @@ f4d50793
fb6dc391
57fdc408
fcf508e3
84848513
83448513
b7d9319d
84848513
83448513
40f23e99
44628522
494244d2
@@ -375,7 +375,7 @@ b7d9319d
4e058082
1eb36309
031300be
48811c43
48811b03
10002737
10003537
431c8846
@@ -416,7 +416,7 @@ feb7e6e3
ce328536
ca3acc2e
c636c876
50c010ef
4f8010ef
475245e2
079346b2
97b3fff5
@@ -469,7 +469,7 @@ cc221101
8522d008
d0483559
688dbf5d
dfc88893
01888893
0108ae83
04852e03
0148a883
@@ -492,12 +492,12 @@ f3638d1d
837201c8
08656763
a3036f8d
6f0ddf4f
ddcf0f13
6f0d010f
ff8f0f13
0533030a
2283006f
650d0005
83c50513
82850513
4108951a
00329313
03169316
@@ -505,7 +505,7 @@ ddcf0f13
4303951a
1ee311c5
a303fe03
2823df4f
2823010f
d11c0105
00231813
010f07b3
@@ -517,7 +517,7 @@ c10cc514
078501d5
85634771
670d02e7
df870713
01470713
4703933a
9f420003
00ff2023
@@ -639,12 +639,12 @@ d24ad426
ce52d04e
6b0dc85e
2703db98
6a8ddf4b
ddca8a93
6a8d010b
ff8a8a93
87b3070a
439400ea
8793678d
97ba83c7
97ba8287
0007a303
00369793
079697b6
@@ -719,15 +719,15 @@ ddca8a93
2e03db98
1b630545
658d2e0e
e6858593
08458593
100003b7
03038393
6e894a51
64896bc1
8e936409
1bfdda8e
77c48493
6bc40413
1bfdd94e
76848493
6a840413
10002737
363749bd
4f851000
@@ -755,7 +755,7 @@ e3fdfff8
565c10f6
561cdbf5
668dfbe5
dfc68693
01868693
453c4ed0
10000737
db0c4599
@@ -770,7 +770,7 @@ db0c4599
000c0563
00361713
270397ba
2883df4b
2883010b
48710545
00271513
00aa86b3
@@ -784,7 +784,7 @@ db0c4599
879310c3
8a630016
668d2d07
df868693
01468693
46839736
9aaa0007
00faa023
@@ -911,7 +911,7 @@ bde1f008
08fc4063
16936789
87930027
070a1287
070a1147
00e50e33
ae8397b6
2883ff47
@@ -932,7 +932,7 @@ ff0041e3
051e2623
08a2658d
01132023
e2858593
04458593
b16d4e05
01e72423
95c2470c
@@ -960,7 +960,7 @@ c2b98a85
658d051e
202308a2
85930113
4e05e285
4e050445
4ca2b935
f0000813
4781bbdd
@@ -981,17 +981,17 @@ bff90785
ca26ce06
db98c84a
2783670d
4689df47
46890107
0785842a
00f6d363
2a234781
2737def7
28234781
273700f7
431c1000
46b14350
8f91078e
2ef6ea63
08136809
450157c8
45015688
10003637
85aa4885
4354431c
@@ -1006,7 +1006,7 @@ fea041e3
02200793
04f49763
8e266809
57c80813
56880813
10002737
48854331
10003637
@@ -1027,7 +1027,7 @@ fea041e3
9b630230
680904f4
08138e26
448157c8
44815688
10002737
48854331
10003637
@@ -1053,7 +1053,7 @@ db104641
866300f4
20231206
09130404
2783dfc9
27830189
c0780109
02f746b3
02f76733
@@ -1062,7 +1062,7 @@ c478c434
01492783
10f6d963
67894458
4cc78793
4b878793
97ba070a
0007a803
27374501
@@ -1092,7 +1092,7 @@ cc10c878
8b890204
18078563
08136809
45012d48
45012c08
10002737
10003637
85aa4885
@@ -1126,7 +1126,7 @@ c0858885
45954942
f06f6105
091384bf
2683dfc9
26830189
46630189
40f206d7
44d24462
@@ -1218,7 +1218,7 @@ f0ef8522
bd81ee2f
c64e1101
8993698d
a703dfc9
a7030189
87930109
c452fff5
02e787b3
@@ -1376,7 +1376,7 @@ f4b50793
f4e50513
d57ddbe5
8493648d
a603dfc4
a6030184
06930ac4
179306c4
8f910036
@@ -1391,7 +1391,7 @@ c2c80106
ae2306c1
13e3feb6
430cfef7
47cd0605
47f50605
4358c28c
4814c2d8
20234458
@@ -1549,7 +1549,7 @@ a0234b0d
e7b90149
0159a023
39198522
57c42783
7ac42783
0513c79d
405c0dc4
07374014
@@ -1563,7 +1563,7 @@ c114db10
61455492
445c8082
05678b63
57842783
7a842783
0513cbb1
b7e10a44
85265064
@@ -1572,8 +1572,8 @@ b7e10a44
fef96be3
11e3c408
2783fb75
cf8d5784
57c42783
cf8d7a84
7ac42783
2737eb95
431c1000
477d4354
@@ -1581,12 +1581,12 @@ cf8d5784
02f76263
17fd445c
00f96e63
56042c23
7a042423
0dc40513
0513b749
bfb506c4
2c23441c
bfb15724
2423441c
bfb17b24
49f25902
4ad24a62
4bb24b42
@@ -1618,151 +1618,146 @@ fef5f8e3
100007b7
db984779
e0ef4581
6489bb1f
359dc62a
7fc48793
6c0d6a8d
6909698d
8a93c43e
0c13ddca
8993df8c
0913dfc9
6b0d7bc9
648d6a0d
14050263
10000d37
030d0d13
063745ed
4bf14000
4c85440d
410006b7
a7034d89
2023000a
2a2300bd
1793de0b
97ba0037
97b20796
c62abb1f
648935a5
87136789
87937e84
6a0d7a87
680d6b8d
c43ec23a
ff8a0a13
014b8b93
01880913
648d6a8d
0063698d
0cb71405
8c931000
466d030c
400006b7
440d4b71
0db74c05
4d094100
000a2703
00cca023
000aa823
00371793
079697ba
c70397b6
ff7511c7
010aa703
00271e93
01da0333
00032303
13630305
43010163
4e03975e
9ed20007
006ea023
001e0313
00670023
10678ea3
10878e23
11c7c703
2703ff75
1e93df4b
83330027
230301da
03050003
01731363
97624301
00074e03
a0239ed6
0313006e
0023001e
8ea30067
8e231067
c7031087
0ee311c7
a703fe87
2a23004a
1793df9b
97ba0037
97b60796
fe870ee3
004a2703
018aa823
00371793
079697ba
c70397ee
ff7511c7
010aa703
00271e93
01da0333
00032303
13630305
43010163
4e03975e
9ed20007
006ea023
001e0313
00670023
10678ea3
10878e23
11c7c703
2703ff75
1e93df4b
83330027
230301da
03050003
01731363
97624301
00074e03
a0239ed6
0313006e
0023001e
8ea30067
8e231067
c7031087
0ee311c7
a703fe87
0337008a
2a234200
1793dfbb
97ba0037
979a0796
fe870ee3
008a2703
42000337
01aaa823
00371793
079697ba
c703979a
ff7511c7
010aa703
00271e93
01da0333
00032303
13630305
43010163
4e03975e
9ed20007
006ea023
001e0313
00670023
10678ea3
10878e23
11c7c703
2703ff75
1e93df4b
83330027
230301da
03050003
01731363
97624301
00074e03
a0239ed6
0313006e
0023001e
8ea30067
8e231067
c7031087
0ee311c7
591cfe87
017d2023
03978763
deca2783
4532e78d
06373331
06b74000
45ed4100
ec051fe3
100037b7
d3d84705
39cd4532
ea051ae3
2623bfe5
3337df9a
27831000
47210283
00f77663
fe870ee3
a023591c
8563016c
a7830387
e39d0084
33294532
400006b7
11e3466d
37b7ee05
47051000
4532d3d8
1ce339d5
bfe5ea05
0184a423
10003337
02832783
fef76ee3
01452f83
02c52f03
02052e83
03452e03
10000337
76634745
278300f7
6ee30283
2f83fef7
2f030145
2e8302c5
2e030205
03370345
37371000
28231000
202300a3
222301f7
242301e7
136301d7
a223060e
59180009
05870a63
2e834281
45a20009
00452f83
002e9313
00658f33
000f2f03
10003737
00a32823
01f72023
01e72223
01d72423
060e1b63
de04a423
0a635918
4f010597
0009ae83
22834822
37370045
93131000
0fb3002e
20230068
934a03e7
00572623
a7034f11
2303000f
66630003
678502ff
2ac78793
37b7973e
aa231000
a8230267
ac2303d7
cbd803c7
cb984518
a423bf3d
8f66df94
4f19b775
fcff7fe3
879377fd
973ed547
a703bfc9
fb51de84
0000b771
03d72823
02572023
01f72623
03c72c23
03e72a23
933a4712
00032703
00fd6663
87936785
973e2ac7
100037b7
4518cbd8
b789cb98
0189a223
b77582e2
0049a703
bf71f355
41f55793
00a7c533
40f50533
@@ -2120,9 +2115,9 @@ ffff0000
1d010000
1c010000
1b010000
0000217c
00002134
00002134
00002168
00002120
00002120
00000002
00000004
00000000
@@ -2354,9 +2349,9 @@ fff50000
002f0000
001f0000
00000000
0000256c
00002534
000024dc
00002558
00002520
000024c8
00000002
00000004
00000006

View File

@@ -35,7 +35,7 @@ module mpeg_video (
output bit event_picture_starts_display,
output event_last_picture_starts_display,
output bit event_first_intra_frame_starts_display,
output [3:0] pictures_in_fifo,
output [4:0] pictures_in_fifo,
output bit [10:0] decoder_width,
output bit [ 8:0] decoder_height,
@@ -490,7 +490,7 @@ module mpeg_video (
dmem_rsp_payload_data_1 = {31'b0, has_sequence_header};
if (dmem_cmd_payload_address_1_q == 32'h10003028)
dmem_rsp_payload_data_1 = {28'b0, pictures_in_fifo_clk_mpeg};
dmem_rsp_payload_data_1 = {27'b0, pictures_in_fifo_clk_mpeg};
if (dmem_cmd_payload_address_1_q == 32'h1000302c)
dmem_rsp_payload_data_1 = {31'b0, playback_active_clkddr};
end
@@ -697,12 +697,12 @@ module mpeg_video (
.flag_out_clk_b(latch_frame_for_display_clk_mpeg)
);
wire [3:0] pictures_in_fifo_clk_mpeg /*verilator public_flat_rd*/;
wire [3:0] pictures_in_fifo_clk_mpeg_gray_d;
bit [3:0] pictures_in_fifo_clk_mpeg_gray_q;
bit [3:0] pictures_in_fifo_clk30_gray;
wire [4:0] pictures_in_fifo_clk_mpeg /*verilator public_flat_rd*/;
wire [4:0] pictures_in_fifo_clk_mpeg_gray_d;
bit [4:0] pictures_in_fifo_clk_mpeg_gray_q;
bit [4:0] pictures_in_fifo_clk30_gray;
b2g_converter #(
.WIDTH(4)
.WIDTH(5)
) pictures_in_fifo_b2g (
.binary((event_at_least_one_frame_clk_mpeg && pictures_in_fifo_clk_mpeg==0) ? 1 : pictures_in_fifo_clk_mpeg),
.gray(pictures_in_fifo_clk_mpeg_gray_d)
@@ -711,7 +711,7 @@ module mpeg_video (
pictures_in_fifo_clk_mpeg_gray_q <= pictures_in_fifo_clk_mpeg_gray_d;
always_ff @(posedge clk30) pictures_in_fifo_clk30_gray <= pictures_in_fifo_clk_mpeg_gray_q;
g2b_converter #(
.WIDTH(4)
.WIDTH(5)
) pictures_in_fifo_g2b (
.binary(pictures_in_fifo),
.gray (pictures_in_fifo_clk30_gray)

View File

@@ -11,16 +11,16 @@ module yuv_frame_adr_fifo (
output bit valid,
output planar_yuv_s q,
// State
output [3:0] cnt
output [4:0] cnt
);
planar_yuv_s ram[16];
planar_yuv_s ram[32];
// Clock domain of output
bit [3:0] raddr; // 512 x 8
bit [4:0] raddr;
// Clock domain of input
bit [3:0] waddr; // 64 x 64
bit [4:0] waddr;
assign cnt = waddr - raddr;
@@ -32,8 +32,8 @@ module yuv_frame_adr_fifo (
ram[waddr] <= wdata;
waddr <= waddr + 1;
assert (cnt < 10);
assert (cnt < 10);
assert (cnt < 28);
assert (cnt < 28);
end
if (strobe) begin

View File

@@ -116,7 +116,7 @@ module vmpeg (
bit fmv_playback_active;
wire fmv_event_sequence_end;
wire fmv_event_buffer_underflow;
wire [3:0] fmv_pictures_in_fifo;
wire [4:0] fmv_pictures_in_fifo;
bit [8:0] latched_display_offset_y;
@@ -463,7 +463,7 @@ module vmpeg (
15'h204E: dout = 0; // e0409c GEN_SYNC_DIFF? Always reads 0 on real machine
15'h204F: dout = 16'hfe96; // e0409e GEN_DEC_DELAY? Always changing but negative?
15'h2050: dout = {1'b0, fmv_decoding_timestamp[21:7]}; // 00E040A0 Decoding Timestamp
15'h2052: dout = {12'b0, fmv_pictures_in_fifo}; // 00E040A4 ?? Pictures in fifo?
15'h2052: dout = {11'b0, fmv_pictures_in_fifo}; // 00E040A4 ?? Pictures in fifo?
15'h2054: dout = fmv_decoder_frameperiod_90khz; // E040A8 Picture Rate Only read.
15'h2055: dout = fmv_display_rate; // e040aa ?? Display Rate ? Only read.
15'h2056: dout = fmv_frame_rate; // e040ac ?? GEN_FRAME_RATE Read and written.

View File

@@ -895,6 +895,7 @@ class CDi {
prevpc = m_pc;
}
#if 0
if (executing_dvc_rom_instructions && dut.rootp->emu__DOT__cditop__DOT__bus_ack &&
(dut.rootp->emu__DOT__cditop__DOT__addr_byte & 0xf00000) != 0xe00000) {
@@ -902,7 +903,7 @@ class CDi {
dut.rootp->emu__DOT__cditop__DOT__addr_byte, dut.rootp->emu__DOT__cditop__DOT__cpu_data,
dut.rootp->emu__DOT__cditop__DOT__uds, dut.rootp->emu__DOT__cditop__DOT__lds);
}
#endif
#endif
// Simulate television

View File

@@ -92,7 +92,7 @@ static void push_frame(plm_frame_t *frame)
__asm volatile("" : : : "memory");
while (frame_display_fifo->pictures_in_fifo > 8)
while (frame_display_fifo->pictures_in_fifo > 17)
__asm volatile("" : : : "memory");
*((volatile plm_frame_t **)OUTPORT_FRAME) = frame;
@@ -124,18 +124,12 @@ static void push_frame(plm_frame_t *frame)
frame_display_fifo->frameperiod_rawhdr = seq_hdr_conf.frameperiod;
frame_display_fifo->temporal_ref = frame->temporal_ref;
if (frame_display_fifo->pictures_in_fifo < 5)
if (frame_display_fifo->pictures_in_fifo < 3)
{
// It seems our FIFO is loosing pictures. Maybe the frame rate is slightly off?
// Increase frame period by 0.1Hz when running at 25 FPS
frame_display_fifo->frameperiod_30mhz = period30mhz + 4780;
}
else if (frame_display_fifo->pictures_in_fifo > 6)
{
// It seems our FIFO is slightly overflowing. Maybe the frame rate is slightly off?
// Decrease frame period by 0.1Hz when running at 25 FPS
frame_display_fifo->frameperiod_30mhz = period30mhz - 4780;
}
else
{
frame_display_fifo->frameperiod_30mhz = period30mhz;

View File

@@ -1973,7 +1973,7 @@ typedef struct {
int v;
} plm_video_motion_t;
#define DDR_FRAMEBUFFER_CNT 20
#define DDR_FRAMEBUFFER_CNT 30
struct plm_video_t {
int time;
@@ -2211,7 +2211,7 @@ void plm_video_allocate_framebuffers(plm_video_t *self)
plm_video_init_frame(self, &self->frame_forward, self->frames_data + frame_data_size * 1);
plm_video_init_frame(self, &self->frame_backward, self->frames_data + frame_data_size * 2);
for (int i=0;i<20;i++)
for (int i=0;i<DDR_FRAMEBUFFER_CNT;i++)
plm_video_init_frame(self, &self->framebuffers[i], self->frames_data + frame_data_size * (3+i));
}

View File

@@ -3,7 +3,7 @@ ENTRY(_start)
MEMORY
{
ram (wxai!r) : ORIGIN = 0x00000000, LENGTH = 13000
ram (wxai!r) : ORIGIN = 0x00000000, LENGTH = 13070
}
SECTIONS