6 #include "schrooperators.h"
8 #define ROUND_UP_SHIFT(x,y) (((x) + (1<<(y)) - 1)>>(y))
9 #define ROUND_UP_POW2(x,y) (((x) + (1<<(y)) - 1)&((~0)<<(y)))
11 void showVideoFormat(SchroVideoFormat
*f
)
13 printf("Video Format:\n");
14 printf(" VideoFormatEnum : %d\n", f
->index
);
15 printf(" Width : %d\n", f
->width
);
16 printf(" Height : %d\n", f
->height
);
17 printf(" Chroma format : %d\n", (int)f
->chroma_format
);
18 printf(" Interlaced : %d\n", f
->interlaced
);
19 printf(" Top field first : %d\n", f
->top_field_first
);
20 printf(" Frame Rate Numerator : %d\n", f
->frame_rate_numerator
);
21 printf(" Frame Rate Denominator : %d\n", f
->frame_rate_denominator
);
22 printf(" Aspect Ratio Numerator : %d\n", f
->aspect_ratio_numerator
);
23 printf(" Aspect Ratio Denominator: %d\n", f
->aspect_ratio_denominator
);
24 printf(" Clean width : %d\n", f
->clean_width
);
25 printf(" Clean height : %d\n", f
->clean_height
);
26 printf(" Left offset : %d\n", f
->left_offset
);
27 printf(" Top offset : %d\n", f
->top_offset
);
28 printf(" Luma offset : %d\n", f
->luma_offset
);
29 printf(" Luma excursion : %d\n", f
->luma_excursion
);
30 printf(" Chroma offset : %d\n", f
->chroma_offset
);
31 printf(" Chroma excursion : %d\n", f
->chroma_excursion
);
32 printf(" Colour primaries : %d\n", f
->colour_primaries
);
33 printf(" Colour matrix : %d\n", f
->colour_matrix
);
34 printf(" Transfer Function : %d\n", f
->transfer_function
);
35 printf(" Interlaced Coding : %d\n", f
->interlaced_coding
);
39 int getMaxSettingNameLength()
42 int n
= schro_encoder_get_n_settings();
44 for(int i
=0; i
<n
; i
++) {
45 const SchroEncoderSetting
*s
= schro_encoder_get_setting_info(i
);
46 int len
= strlen(s
->name
);
47 if(len
> maxlen
) maxlen
= len
;
53 void showEncoderSettings(SchroEncoder
*encoder
)
55 int n
= schro_encoder_get_n_settings();
56 int maxlen
= getMaxSettingNameLength();
58 printf("Encoder Settings:\n");
60 for(int i
=0; i
<n
; i
++) {
61 const SchroEncoderSetting
*s
= schro_encoder_get_setting_info(i
);
62 double val
= schro_encoder_setting_get_double(encoder
, s
->name
);
64 printf(" %s%.*s", s
->name
, (int)(maxlen
-strlen(s
->name
)+1), " ");
67 case SCHRO_ENCODER_SETTING_TYPE_BOOLEAN
:
68 printf("BOOL %d\n", (int)val
);
71 case SCHRO_ENCODER_SETTING_TYPE_INT
:
72 printf("INT %d\n", (int)val
);
75 case SCHRO_ENCODER_SETTING_TYPE_DOUBLE
:
76 printf("DOUBLE %g\n", val
);
79 case SCHRO_ENCODER_SETTING_TYPE_ENUM
:
80 printf("ENUM %s\n", s
->enum_list
[(int)val
]);
92 frame_new_from_data_u8_planar422 (unsigned char *data
, int width
, int height
)
94 SchroFrame
*frame
= schro_frame_new();
96 frame
->format
= SCHRO_FRAME_FORMAT_U8_422
;
99 frame
->height
= height
;
101 frame
->components
[0].width
= width
;
102 frame
->components
[0].height
= height
;
103 frame
->components
[0].stride
= ROUND_UP_POW2(width
,2);
104 frame
->components
[0].data
= data
;
105 frame
->components
[0].length
= frame
->components
[0].stride
*
106 ROUND_UP_POW2(frame
->components
[0].height
,1);
107 frame
->components
[0].v_shift
= 0;
108 frame
->components
[0].h_shift
= 0;
110 frame
->components
[1].width
= ROUND_UP_SHIFT(width
,1);
111 frame
->components
[1].height
= height
;
112 frame
->components
[1].stride
= ROUND_UP_POW2(frame
->components
[1].width
,2);
113 frame
->components
[1].length
=
114 frame
->components
[1].stride
* frame
->components
[1].height
;
115 frame
->components
[1].data
= data
+ frame
->components
[0].length
;
116 frame
->components
[1].v_shift
= 0;
117 frame
->components
[1].h_shift
= 1;
119 frame
->components
[2].width
= ROUND_UP_SHIFT(width
,1);
120 frame
->components
[2].height
= height
;
121 frame
->components
[2].stride
= ROUND_UP_POW2(frame
->components
[2].width
,2);
122 frame
->components
[2].length
=
123 frame
->components
[2].stride
* frame
->components
[2].height
;
124 frame
->components
[2].data
= data
+ frame
->components
[0].length
+ frame
->components
[1].length
;
125 frame
->components
[2].v_shift
= 0;
126 frame
->components
[2].h_shift
= 1;
132 frame_new_from_data_u8_planar444 (unsigned char *data
, int width
, int height
)
134 SchroFrame
*frame
= schro_frame_new();
136 frame
->format
= SCHRO_FRAME_FORMAT_U8_444
;
138 frame
->width
= width
;
139 frame
->height
= height
;
141 frame
->components
[0].width
= width
;
142 frame
->components
[0].height
= height
;
143 frame
->components
[0].stride
= ROUND_UP_POW2(width
,2);
144 frame
->components
[0].data
= data
;
145 frame
->components
[0].length
= frame
->components
[0].stride
*
146 ROUND_UP_POW2(frame
->components
[0].height
,1);
147 frame
->components
[0].v_shift
= 0;
148 frame
->components
[0].h_shift
= 0;
150 frame
->components
[1].width
= width
;
151 frame
->components
[1].height
= height
;
152 frame
->components
[1].stride
= ROUND_UP_POW2(frame
->components
[1].width
,2);
153 frame
->components
[1].length
=
154 frame
->components
[1].stride
* frame
->components
[1].height
;
155 frame
->components
[1].data
= data
+ frame
->components
[0].length
;
156 frame
->components
[1].v_shift
= 0;
157 frame
->components
[1].h_shift
= 0;
159 frame
->components
[2].width
= width
;
160 frame
->components
[2].height
= height
;
161 frame
->components
[2].stride
= ROUND_UP_POW2(frame
->components
[2].width
,2);
162 frame
->components
[2].length
=
163 frame
->components
[2].stride
* frame
->components
[2].height
;
164 frame
->components
[2].data
= data
+ frame
->components
[0].length
+ frame
->components
[1].length
;
165 frame
->components
[2].v_shift
= 0;
166 frame
->components
[2].h_shift
= 0;