int ms_yuv_buf_init_from_mblk(YuvBuf *buf, mblk_t *m){ int w,h; // read header mblk_video_header* hdr = (mblk_video_header*)m->b_datap->db_base; w = hdr->w; h = hdr->h; if (m->b_cont == NULL) yuv_buf_init(buf,w,h,m->b_rptr); else yuv_buf_init(buf,w,h,m->b_cont->b_rptr); return 0; }
mblk_t *ms_yuv_buf_allocator_get(MSYuvBufAllocator *obj, MSPicture *buf, int w, int h) { int size=(w * (h & 0x1 ? h+1 : h) *3)/2; /*swscale doesn't like odd numbers of line*/ const int header_size = sizeof(mblk_video_header); const int padding=16; mblk_t *msg = msgb_allocator_alloc(obj, header_size + size+padding); mblk_video_header* hdr = (mblk_video_header*)msg->b_wptr; hdr->w = w; hdr->h = h; msg->b_rptr += header_size; msg->b_wptr += header_size; yuv_buf_init(buf,w,h,msg->b_wptr); msg->b_wptr+=size; return msg; }
mblk_t * ms_yuv_buf_alloc(YuvBuf *buf, int w, int h){ int size=(w*h*3)/2; const int header_size =sizeof(mblk_video_header); const int padding=16; mblk_t *msg=allocb(header_size + size+padding,0); // write width/height in header mblk_video_header* hdr = (mblk_video_header*)msg->b_wptr; hdr->w = w; hdr->h = h; msg->b_rptr += header_size; msg->b_wptr += header_size; yuv_buf_init(buf,w,h,msg->b_wptr); msg->b_wptr+=size; return msg; }
mblk_t * ms_yuv_buf_alloc(YuvBuf *buf, int w, int h){ int size=(w * (h & 0x1 ? h+1 : h) *3)/2; /*swscale doesn't like odd numbers of line*/ const int header_size = sizeof(mblk_video_header); const int padding=16; mblk_t *msg=allocb(header_size + size+padding,0); // write width/height in header mblk_video_header* hdr = (mblk_video_header*)msg->b_wptr; hdr->w = w; hdr->h = h; msg->b_rptr += header_size; msg->b_wptr += header_size; yuv_buf_init(buf,w,h,msg->b_wptr); msg->b_wptr+=size; return msg; }
int ms_yuv_buf_init_from_mblk_with_size(YuvBuf *buf, mblk_t *m, int w, int h){ if (m->b_cont!=NULL) m=m->b_cont; /*skip potential video header */ yuv_buf_init(buf,w,h,m->b_rptr); return 0; }