@@ -68,107 +68,16 @@ static int validate_videos(video_input *vid1, video_input *vid2, bool common_bit
6868 return err_cnt ;
6969}
7070
71- // Copy video input data to picture buffer
72- static void copy_picture_data (VmafPicture * pic , video_input_ycbcr ycbcr ,
73- video_input_info * info , int depth )
71+ static int fetch_picture (VmafContext * vmaf , video_input * vid , VmafPicture * pic )
7472{
75- if (info -> depth == depth ) {
76- if (info -> depth == 8 ) {
77- for (unsigned i = 0 ; i < 3 ; i ++ ) {
78- int xdec = i && !(info -> pixel_fmt & 1 );
79- int ydec = i && !(info -> pixel_fmt & 2 );
80- uint8_t * ycbcr_data = ycbcr [i ].data +
81- (info -> pic_y >> ydec ) * ycbcr [i ].stride +
82- (info -> pic_x >> xdec );
83- uint8_t * pic_data = pic -> data [i ];
84-
85- for (unsigned j = 0 ; j < pic -> h [i ]; j ++ ) {
86- memcpy (pic_data , ycbcr_data , sizeof (* pic_data ) * pic -> w [i ]);
87- pic_data += pic -> stride [i ];
88- ycbcr_data += ycbcr [i ].stride ;
89- }
90- }
91- } else {
92- for (unsigned i = 0 ; i < 3 ; i ++ ) {
93- int xdec = i && !(info -> pixel_fmt & 1 );
94- int ydec = i && !(info -> pixel_fmt & 2 );
95- uint16_t * ycbcr_data = (uint16_t * ) ycbcr [i ].data +
96- (info -> pic_y >> ydec ) * (ycbcr [i ].stride / 2 ) +
97- (info -> pic_x >> xdec );
98- uint16_t * pic_data = pic -> data [i ];
99-
100- for (unsigned j = 0 ; j < pic -> h [i ]; j ++ ) {
101- memcpy (pic_data , ycbcr_data , sizeof (* pic_data ) * pic -> w [i ]);
102- pic_data += pic -> stride [i ] / 2 ;
103- ycbcr_data += ycbcr [i ].stride / 2 ;
104- }
105- }
106- }
107- } else if (depth > 8 ) {
108- // unequal bit-depth
109- // therefore depth must be > 8 since we do not support depth < 8
110- int left_shift = depth - info -> depth ;
111- if (info -> depth == 8 ) {
112- for (unsigned i = 0 ; i < 3 ; i ++ ) {
113- int xdec = i && !(info -> pixel_fmt & 1 );
114- int ydec = i && !(info -> pixel_fmt & 2 );
115- uint8_t * ycbcr_data = ycbcr [i ].data +
116- (info -> pic_y >> ydec ) * ycbcr [i ].stride +
117- (info -> pic_x >> xdec );
118- uint16_t * pic_data = (uint16_t * )pic -> data [i ];
119-
120- for (unsigned j = 0 ; j < pic -> h [i ]; j ++ ) {
121- for (unsigned k = 0 ; k < pic -> w [i ]; k ++ ) {
122- pic_data [k ] = ycbcr_data [k ] << left_shift ;
123- }
124- pic_data += pic -> stride [i ] / 2 ;
125- ycbcr_data += ycbcr [i ].stride ;
126- }
127- }
128- } else {
129- for (unsigned i = 0 ; i < 3 ; i ++ ) {
130- int xdec = i && !(info -> pixel_fmt & 1 );
131- int ydec = i && !(info -> pixel_fmt & 2 );
132- uint16_t * ycbcr_data = (uint16_t * ) ycbcr [i ].data +
133- (info -> pic_y >> ydec ) * (ycbcr [i ].stride / 2 ) +
134- (info -> pic_x >> xdec );
135- uint16_t * pic_data = pic -> data [i ];
136-
137- for (unsigned j = 0 ; j < pic -> h [i ]; j ++ ) {
138- for (unsigned k = 0 ; k < pic -> w [i ]; k ++ ) {
139- pic_data [k ] = ycbcr_data [k ] << left_shift ;
140- }
141- pic_data += pic -> stride [i ] / 2 ;
142- ycbcr_data += ycbcr [i ].stride / 2 ;
143- }
144- }
145- }
146- }
147- }
148-
149- static int fetch_picture (VmafContext * vmaf , video_input * vid , VmafPicture * pic ,
150- int depth )
151- {
152- int ret ;
153- video_input_info info ;
154- video_input_get_info (vid , & info );
155-
156- (void ) depth ;
157- ret = vmaf_fetch_preallocated_picture (vmaf , pic );
73+ int ret = vmaf_fetch_preallocated_picture (vmaf , pic );
15874 if (ret ) {
15975 fprintf (stderr , "problem fetching picture from pool.\n" );
16076 return -1 ;
16177 }
16278
163- #ifdef USE_DIRECT_READ
16479 ret = video_input_fetch_into_vmaf_picture (vid , pic );
16580 if (ret < 1 ) return !ret ;
166- #else
167- video_input_ycbcr ycbcr ;
168- ret = video_input_fetch_frame (vid , ycbcr , NULL );
169- if (ret < 1 ) return !ret ;
170- copy_picture_data (pic , ycbcr , & info , info .depth );
171- #endif
17281 return 0 ;
17382}
17483
@@ -413,10 +322,10 @@ int main(int argc, char *argv[])
413322 VmafPicture pic_ref , pic_dist ;
414323
415324 for (unsigned i = 0 ; i < c .frame_skip_ref ; i ++ )
416- fetch_picture (vmaf , & vid_ref , & pic_ref , common_bitdepth );
325+ fetch_picture (vmaf , & vid_ref , & pic_ref );
417326
418327 for (unsigned i = 0 ; i < c .frame_skip_dist ; i ++ )
419- fetch_picture (vmaf , & vid_dist , & pic_dist , common_bitdepth );
328+ fetch_picture (vmaf , & vid_dist , & pic_dist );
420329
421330 float fps = 0. ;
422331 const time_t t0 = clock ();
@@ -427,8 +336,8 @@ int main(int argc, char *argv[])
427336 break ;
428337
429338 VmafPicture pic_ref , pic_dist ;
430- int ret1 = fetch_picture (vmaf , & vid_ref , & pic_ref , common_bitdepth );
431- int ret2 = fetch_picture (vmaf , & vid_dist , & pic_dist , common_bitdepth );
339+ int ret1 = fetch_picture (vmaf , & vid_ref , & pic_ref );
340+ int ret2 = fetch_picture (vmaf , & vid_dist , & pic_dist );
432341
433342 if (ret1 && ret2 ) {
434343 break ;
0 commit comments