forked from h26forge/h26forge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclear_out_frames.py
34 lines (26 loc) · 1.46 KB
/
clear_out_frames.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def clear_out_frames(ds):
from helpers import is_slice_type, new_vui_parameter
from slice_all_remove_residue import slice_all_remove_residue
# Remove VUI information
for i in range(len(ds["spses"])):
ds["spses"][i]["vui_parameters_present_flag"] = False
# this is to prevent dependent variables from using stale data in the encoder
ds["spses"][i]["vui_parameters"] = new_vui_parameter()
# Ignore Inter by setting mb_skip_flag to True
for i in range(len(ds["slices"])):
slice_type = ds["slices"][i]["sh"]["slice_type"]
if is_slice_type(slice_type, "I"):
for j in range(len(ds["slices"][i]["sd"]["macroblock_vec"])):
ds["slices"][i]["sd"]["macroblock_vec"][j]["mb_type"] = "INxN"
ds["slices"][i]["sd"]["macroblock_vec"][j]["transform_size_8x8_flag"] = True
ds["slices"][i]["sd"]["macroblock_vec"][j]["intra_chroma_pred_mode"] = 0
ds["slices"][i]["sd"]["macroblock_vec"][j]["prev_intra8x8_pred_mode_flag"] = [True]*4
if is_slice_type(slice_type, "P") or is_slice_type(slice_type, "B"):
for j in range(len(ds["slices"][i]["sd"]["macroblock_vec"])):
ds["slices"][i]["sd"]["macroblock_vec"][j]["mb_skip_flag"] = True
# Now that we've updated the MB Type,
# remove all the residue information from each frame
ds = slice_all_remove_residue(ds)
return ds
def modify_video(ds):
return clear_out_frames(ds)