Home | History | Annotate | Download | only in tests
      1 /*
      2  * test_inline.h - test inline header
      3  *
      4  *  Copyright (c) 2017 Intel Corporation
      5  *
      6  * Licensed under the Apache License, Version 2.0 (the "License");
      7  * you may not use this file except in compliance with the License.
      8  * You may obtain a copy of the License at
      9  *
     10  *      http://www.apache.org/licenses/LICENSE-2.0
     11  *
     12  * Unless required by applicable law or agreed to in writing, software
     13  * distributed under the License is distributed on an "AS IS" BASIS,
     14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15  * See the License for the specific language governing permissions and
     16  * limitations under the License.
     17  *
     18  * Author: Wind Yuan <feng.yuan (at) intel.com>
     19  *         Yinhang Liu <yinhangx.liu (at) intel.com>
     20  */
     21 
     22 #ifndef XCAM_TEST_INLINE_H
     23 #define XCAM_TEST_INLINE_H
     24 
     25 #include <video_buffer.h>
     26 
     27 using namespace XCam;
     28 
     29 inline static void
     30 ensure_gpu_buffer_done (SmartPtr<VideoBuffer> buf)
     31 {
     32     const VideoBufferInfo info = buf->get_video_info ();
     33     VideoBufferPlanarInfo planar;
     34     uint8_t *memory = NULL;
     35 
     36     memory = buf->map ();
     37     for (uint32_t index = 0; index < info.components; index++) {
     38         info.get_planar_info (planar, index);
     39         uint32_t line_bytes = planar.width * planar.pixel_bytes;
     40 
     41         for (uint32_t i = 0; i < planar.height; i++) {
     42             int mem_idx = info.offsets [index] + i * info.strides [index] + line_bytes - 1;
     43             if (memory[mem_idx] == 1) {
     44                 memory[mem_idx] = 1;
     45             }
     46         }
     47     }
     48     buf->unmap ();
     49 }
     50 
     51 #endif // XCAM_TEST_INLINE_H
     52