Ignore:
Timestamp:
Jul 29, 2019 2:25:34 AM (5 years ago)
Author:
nanang
Message:

Misc (re #2210): Added format definitions for NV12 & NV21.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/format.c

    r5642 r6046  
    6464                                    pjmedia_video_apply_fmt_param *aparam); 
    6565 
     66static pj_status_t apply_biplanar_420(const pjmedia_video_format_info *fi, 
     67                                      pjmedia_video_apply_fmt_param *aparam); 
     68 
    6669struct pjmedia_video_format_mgr 
    6770{ 
     
    8891    {PJMEDIA_FORMAT_I420JPEG, "I420JPG", PJMEDIA_COLOR_MODEL_YUV, 12, 3, &apply_planar_420}, 
    8992    {PJMEDIA_FORMAT_I422JPEG, "I422JPG", PJMEDIA_COLOR_MODEL_YUV, 16, 3, &apply_planar_422}, 
     93    {PJMEDIA_FORMAT_NV12,  "NV12", PJMEDIA_COLOR_MODEL_YUV, 12, 2, &apply_biplanar_420}, 
     94    {PJMEDIA_FORMAT_NV21,  "NV21", PJMEDIA_COLOR_MODEL_YUV, 12, 2, &apply_biplanar_420}, 
    9095}; 
    9196 
     
    261266    return PJ_SUCCESS; 
    262267} 
     268 
     269static pj_status_t apply_biplanar_420(const pjmedia_video_format_info *fi, 
     270                                      pjmedia_video_apply_fmt_param *aparam) 
     271{ 
     272    unsigned i; 
     273    pj_size_t Y_bytes; 
     274 
     275    PJ_UNUSED_ARG(fi); 
     276 
     277    /* Calculate memsize */ 
     278    Y_bytes = (pj_size_t)(aparam->size.w * aparam->size.h); 
     279    aparam->framebytes = Y_bytes + (Y_bytes>>1); 
     280 
     281    /* Planar formats use 2 plane */ 
     282    aparam->strides[0] = aparam->size.w; 
     283    aparam->strides[1] = aparam->size.w; 
     284 
     285    aparam->planes[0] = aparam->buffer; 
     286    aparam->planes[1] = aparam->planes[0] + Y_bytes; 
     287 
     288    aparam->plane_bytes[0] = Y_bytes; 
     289    aparam->plane_bytes[1] = (Y_bytes>>1); 
     290 
     291    /* Zero unused planes */ 
     292    for (i=2; i<PJMEDIA_MAX_VIDEO_PLANES; ++i) { 
     293        aparam->strides[i] = 0; 
     294        aparam->planes[i] = NULL; 
     295        aparam->plane_bytes[i] = 0; 
     296    } 
     297 
     298    return PJ_SUCCESS; 
     299} 
     300 
    263301 
    264302PJ_DEF(pj_status_t) 
Note: See TracChangeset for help on using the changeset viewer.