首页 > 代码库 > 第11月第8天 ffmpeg ffplay

第11月第8天 ffmpeg ffplay

1.

static int func_fill_frame(SDL_VoutOverlay *overlay, const AVFrame *frame){    assert(overlay);    SDL_VoutOverlay_Opaque *opaque = overlay->opaque;    AVFrame swscale_dst_pic = { { 0 } };    av_frame_unref(opaque->linked_frame);    int need_swap_uv = 0;    int use_linked_frame = 0;    enum AVPixelFormat dst_format = AV_PIX_FMT_NONE;    switch (overlay->format) {        case SDL_FCC_YV12:            need_swap_uv = 1;            // no break;        case SDL_FCC_I420:            if (frame->format == AV_PIX_FMT_YUV420P || frame->format == AV_PIX_FMT_YUVJ420P) {                // ALOGE("direct draw frame");                use_linked_frame = 1;                dst_format = frame->format;            } else {                // ALOGE("copy draw frame");                dst_format = AV_PIX_FMT_YUV420P;            }            break;        case SDL_FCC_I444P10LE:            if (frame->format == AV_PIX_FMT_YUV444P10LE) {                // ALOGE("direct draw frame");                use_linked_frame = 1;                dst_format = frame->format;            } else {                // ALOGE("copy draw frame");                dst_format = AV_PIX_FMT_YUV444P10LE;            }            break;        case SDL_FCC_RV32:            dst_format = AV_PIX_FMT_0BGR32;            break;        case SDL_FCC_RV24:            dst_format = AV_PIX_FMT_RGB24;            break;        case SDL_FCC_RV16:            dst_format = AV_PIX_FMT_RGB565;            break;        default:            ALOGE("SDL_VoutFFmpeg_ConvertPicture: unexpected overlay format %s(%d)",                  (char*)&overlay->format, overlay->format);            return -1;    }    // setup frame    if (use_linked_frame) {        // linked frame        av_frame_ref(opaque->linked_frame, frame);        overlay_fill(overlay, opaque->linked_frame, opaque->planes);...static void overlay_fill(SDL_VoutOverlay *overlay, AVFrame *frame, int planes){    overlay->planes = planes;    for (int i = 0; i < AV_NUM_DATA_POINTERS; ++i) {        overlay->pixels[i] = frame->data[i];        overlay->pitches[i] = frame->linesize[i];    }}...static GLboolean yuv420p_uploadTexture(IJK_GLES2_Renderer *renderer, SDL_VoutOverlay *overlay){    if (!renderer || !overlay)        return GL_FALSE;          int     planes[3]    = { 0, 1, 2 };    const GLsizei widths[3]    = { overlay->pitches[0], overlay->pitches[1], overlay->pitches[2] };    const GLsizei heights[3]   = { overlay->h,          overlay->h / 2,      overlay->h / 2 };    const GLubyte *pixels[3]   = { overlay->pixels[0],  overlay->pixels[1],  overlay->pixels[2] };    switch (overlay->format) {        case SDL_FCC_I420:            break;        case SDL_FCC_YV12:            planes[1] = 2;            planes[2] = 1;            break;        default:            ALOGE("[yuv420p] unexpected format %x\n", overlay->format);            return GL_FALSE;    }    for (int i = 0; i < 3; ++i) {        int plane = planes[i];        glBindTexture(GL_TEXTURE_2D, renderer->plane_textures[i]);        glTexImage2D(GL_TEXTURE_2D,                     0,                     GL_LUMINANCE,                     widths[plane],                     heights[plane],                     0,                     GL_LUMINANCE,                     GL_UNSIGNED_BYTE,                     pixels[plane]);    }    return GL_TRUE;}

 

http://blog.csdn.net/liujiakunit/article/details/46899229

 

第11月第8天 ffmpeg ffplay