palmman
15th April 2010, 11:40
Hi guys,
If a video squence is I1 B2 B3 P4 I5 P6.
It has two GOPs, "I1 B2 B3 P4" and "I5 P6".
Normally, the encoding order is as below.
Condition: 2 thread, frame level parallelism.
1. I1
2. P4
3. B2 B3
4. I5
5. P6
Now I would like to adjust the order.
1. I1 I5
2. P4 P6
3. B2 B3
How to implement it?
My idea is parse whole video, and decide all frame type before encoding, then use two reference buffers for GOP1 and GOP2.
I modify variable structure, frames.
struct
{
...
x264_frame_t *unused[2][X264_LOOKAHEAD_MAX + X264_THREAD_MAX*2 + 16+4];
...
x264_frame_t *reference[2][16+2];
...
} frames;
And modify function "write_nalu_bsf", I allocate two memory blocks for GOP1 and GOP2, respectively.
These already encoded frames will be stored in memory block temporarily.
After encoding finish, memory1 and memory2 will be wtired into file in turn.
But I meet a question. Attached file is the output video (18frames), it looks stranger and file size is different from original.
I don't know whether somewhere I miss to modify. Could someone help me, very thanks.
P.S. The version of x264 is "x264-snapshot-20090831-2245.tar.bz2".
If a video squence is I1 B2 B3 P4 I5 P6.
It has two GOPs, "I1 B2 B3 P4" and "I5 P6".
Normally, the encoding order is as below.
Condition: 2 thread, frame level parallelism.
1. I1
2. P4
3. B2 B3
4. I5
5. P6
Now I would like to adjust the order.
1. I1 I5
2. P4 P6
3. B2 B3
How to implement it?
My idea is parse whole video, and decide all frame type before encoding, then use two reference buffers for GOP1 and GOP2.
I modify variable structure, frames.
struct
{
...
x264_frame_t *unused[2][X264_LOOKAHEAD_MAX + X264_THREAD_MAX*2 + 16+4];
...
x264_frame_t *reference[2][16+2];
...
} frames;
And modify function "write_nalu_bsf", I allocate two memory blocks for GOP1 and GOP2, respectively.
These already encoded frames will be stored in memory block temporarily.
After encoding finish, memory1 and memory2 will be wtired into file in turn.
But I meet a question. Attached file is the output video (18frames), it looks stranger and file size is different from original.
I don't know whether somewhere I miss to modify. Could someone help me, very thanks.
P.S. The version of x264 is "x264-snapshot-20090831-2245.tar.bz2".