static inline void set_nv12_sizes(const struct obs_video_info *ovi) { struct obs_core_video *video = &obs->video; uint32_t chroma_pixels; uint32_t total_bytes; chroma_pixels = (ovi->output_width * ovi->output_height / 2); chroma_pixels = GET_ALIGN(chroma_pixels, PIXEL_SIZE); video->plane_offsets[0] = 0; video->plane_offsets[1] = ovi->output_width * ovi->output_height; video->plane_linewidth[0] = ovi->output_width; video->plane_linewidth[1] = ovi->output_width; video->plane_sizes[0] = video->plane_offsets[1]; video->plane_sizes[1] = video->plane_sizes[0]/2; total_bytes = video->plane_offsets[1] + chroma_pixels; video->conversion_height = (total_bytes/PIXEL_SIZE + ovi->output_width-1) / ovi->output_width; video->conversion_height = GET_ALIGN(video->conversion_height, 2); video->conversion_tech = "NV12"; }
HL_PRIM int hl_pad_struct( int size, hl_type *t ) { int align = sizeof(void*); # define GET_ALIGN(type) { struct { unsigned char a; type b; } s = {0}; align = (int)((unsigned char *)&s.b - (unsigned char*)&s); } switch( t->kind ) { case HVOID: return 0; case HUI8: GET_ALIGN(unsigned char); break; case HUI16: GET_ALIGN(unsigned short); break; case HI32: GET_ALIGN(unsigned int); break; case HI64: GET_ALIGN(int64); break; case HF32: GET_ALIGN(float); break; case HF64: GET_ALIGN(double); break; case HBOOL: GET_ALIGN(bool); break; default: break; } return (-size) & (align - 1); }