Changeset 6046


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

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

Location:
pjproject/trunk/pjmedia
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/format.h

    r4994 r6046  
    177177    PJMEDIA_FORMAT_YV12     = PJMEDIA_FORMAT_PACK('Y', 'V', '1', '2'), 
    178178 
     179    /** 
     180     * This is planar 4:2:0/12bpp YUV format, the data can be treated as 
     181     * two planes of color components, where the first plane contains 
     182     * only the Y samples, the second plane contains interleaved 
     183     * U (Cb) - V (Cr) samples. 
     184     */ 
     185    PJMEDIA_FORMAT_NV12     = PJMEDIA_FORMAT_PACK('N', 'V', '1', '2'), 
     186     
    179187    /** 
    180188     * This is planar 4:2:0/12bpp YUV format, the data can be treated as 
  • pjproject/trunk/pjmedia/src/pjmedia/ffmpeg_util.c

    r5306 r6046  
    4848    { PJMEDIA_FORMAT_I420JPEG, AV(PIX_FMT_YUVJ420P)}, 
    4949    { PJMEDIA_FORMAT_I422JPEG, AV(PIX_FMT_YUVJ422P)}, 
     50    { PJMEDIA_FORMAT_NV12, AV(PIX_FMT_NV12)}, 
     51    { PJMEDIA_FORMAT_NV21, AV(PIX_FMT_NV21)}, 
    5052}; 
    5153 
  • 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.