How to encode frames in decoding order?

NV_ENC_PIC_PARAMS picParams{};
  picParams.pictureType = output.picType == 'I'   ? NV_ENC_PIC_TYPE_IDR
                          : output.picType == 'P' ? NV_ENC_PIC_TYPE_P
                                                  : NV_ENC_PIC_TYPE_B;
  picParams.frameIdx = output.decodingOrderIdx;
  picParams.codecPicParams.hevcPicParams.displayPOCSyntax = 2 * output.displayOrderIdx;
  picParams.codecPicParams.hevcPicParams.refPicFlag = output.refPicFlag;

  pEnc->EncodeFrame(vPacket, &picParams);

I tried using this code where I developed my own GOP structure generation algorithm and applied it to NVENC encoding.

However, it didn’t work as expected, and the output exhibited reference picture mismatches.

How can I encode frames in the order of decoding? I intend to use this function for iterative encoding.

Additionally, this is GOP structure what i used. (bframes=7, keyframe Interval=53)

decoding(encoding) order display order picture type
0 0 I
1 8 P
2 4 B
3 1 B
4 2 B
5 3 B
6 5 B
7 6 B
8 7 B
9 16 P
10 12 B
11 9 B
12 10 B
13 11 B
14 13 B
15 14 B
16 15 B
17 24 P
18 20 B
19 17 B
20 18 B
21 19 B
22 21 B
23 22 B
24 23 B
25 32 P
26 28 B
27 25 B
28 26 B
29 27 B
30 29 B
31 30 B
32 31 B
33 40 P
34 36 B
35 33 B
36 34 B
37 35 B
38 37 B
39 38 B
40 39 B
41 48 P
42 44 B
43 41 B
44 42 B
45 43 B
46 45 B
47 46 B
48 47 B
49 52 P
50 50 B
51 49 B
52 51 B
53 53 I

I resolved this issues with
replacing
picParams.codecPicParams.hevcPicParams.displayPOCSyntax = 2 * output.displayOrderIdx;
to
picParams.codecPicParams.hevcPicParams.displayPOCSyntax = 2 * (output.displayOrderIdx % keyFrameInterval);

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.