提交 0c7b54c3 编写于 作者: Z Zhang Rui

jni: ijkplayer: introduce SDL_Overlay, SDL_Surface

上级 aec1153f
......@@ -88,11 +88,7 @@ typedef struct PacketQueue {
typedef struct VideoPicture {
double pts; // presentation timestamp for this picture
int64_t pos; // byte position in file
#ifdef IJK_FFPLAY_MERGE
SDL_Overlay *bmp;
#else
SDL_Picture *bmp;
#endif
int width, height; /* source height & width */
AVRational sample_aspect_ratio;
int allocated;
......@@ -333,8 +329,10 @@ typedef struct FFPlayer {
const char *window_title;
int fs_screen_width;
int fs_screen_height;
int default_width = 640;
int default_height = 480;
#endif
int default_width;
int default_height;
#ifdef IJK_FFPLAY_MERGE
int screen_width = 0;
int screen_height = 0;
#endif
......@@ -386,9 +384,11 @@ typedef struct FFPlayer {
int is_full_screen;
#endif
int64_t audio_callback_time;
SDL_Surface *screen;
/* extra fields */
SDL_Vout *vout;
int sar_num;
int sar_den;
} FFPlayer;
#define IJKFF_SAFE_FREE(p) do {free(p); p = NULL;} while(0)
......@@ -404,6 +404,8 @@ inline static void ijkff_reset(FFPlayer *ffp)
/* ffplay options specified by the user */
IJKFF_SAFE_FREE(ffp->input_filename);
ffp->default_width = 640;
ffp->default_height = 480;
ffp->audio_disable = 0;
ffp->video_disable = 0;
ffp->subtitle_disable = 0;
......@@ -443,10 +445,12 @@ inline static void ijkff_reset(FFPlayer *ffp)
/* current context */
ffp->audio_callback_time = 0;
SDL_FreeSurface(ffp->screen);
ffp->screen = NULL;
/* extra fields */
SDL_VoutFree(ffp->vout);
ffp->vout = NULL;
ffp->sar_num = 0;
ffp->sar_den = 0;
}
#endif
/*****************************************************************************
* ffplay_output_video_thread.c
*****************************************************************************
*
* copyright (c) 2001 Fabrice Bellard
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if 0
static int video_open(FFPlayer *ffp, int force_set_video_mode, VideoPicture *vp)
{
VideoState *is = &ffp->is;
SDL_Vout *vout = ffp->vout;
int w = 0;
int h = 0;
SDL_Rect rect;
if (!vp)
return 0;
if (vp && vp->width && vp->height) {
w = rect.w;
h = rect.h;
}
if (vout &&
is->width == vout->width && vout->width == w &&
is->height == vout->height && vout->height == h &&
!force_set_video_mode)
return 0;
if (SDL_VoutSetBuffersGeometry(vout, w, h, 0))
{
ALOGE("SDL_SetBuffersGeometry(%d, %d, 0) failed");
return -1;
}
is->width = vout->width;
is->height = vout->height;
return 0;
}
/* display the current picture, if any */
static void video_display(FFPlayer *ffp)
{
VideoState *is = &ffp->is;
VideoPicture *vp = NULL;
if (!is->video_st)
return;
vp = &is->pictq[is->pictq_rindex];
if (vp && video_open(ffp, 0, vp))
return;
if (ffp->vout && vp)
SDL_VoutRender(ffp->vout, vp->bmp);
}
#endif
......@@ -28,7 +28,7 @@ LOCAL_SRC_FILES += ijksdl_mutex.c
LOCAL_SRC_FILES += ijksdl_stdinc.c
LOCAL_SRC_FILES += ijksdl_thread.c
LOCAL_SRC_FILES += ijksdl_timer.c
LOCAL_SRC_FILES += ijksdl_vout.c
LOCAL_SRC_FILES += ijksdl_video.c
LOCAL_MODULE := ijksdl
include $(BUILD_STATIC_LIBRARY)
......@@ -28,9 +28,8 @@
#include "ijksdl_events.h"
#include "ijksdl_error.h"
#include "ijksdl_mutex.h"
#include "ijksdl_rect.h"
#include "ijksdl_thread.h"
#include "ijksdl_timer.h"
#include "ijksdl_vout.h"
#include "ijksdl_video.h"
#endif
/*****************************************************************************
* ijksdl_rect.h
*****************************************************************************
*
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IJKSDL__IJKSDL_RECT_H
#define IJKSDL__IJKSDL_RECT_H
typedef struct SDL_Rect
{
int x, y;
int w, h;
} SDL_Rect;
#endif
/*****************************************************************************
* ijksdl_vout.h
* ijksdl_video.c
*****************************************************************************
*
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
......@@ -21,48 +21,44 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "ijksdl_vout.h"
#include <stdlib.h>
#include "ijksdl_video.h"
SDL_Vout *SDL_VoutCreate()
void SDL_FreeSurface(SDL_Surface *surface)
{
SDL_Vout *vout = malloc(sizeof(SDL_Vout));
memset(vout, 0, sizeof(SDL_Vout));
/* FIXME: implement */
return vout;
// FIXME: implement
}
void SDL_VoutFree(SDL_Vout *vout)
SDL_Overlay *SDL_CreateYUVOverlay(int width, int height,
Uint32 format, SDL_Surface *display)
{
if (!vout)
return;
/* FIXME: implement */
// FIXME: implement
return NULL;
}
free(vout);
SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
{
// FIXME: implement
return NULL;
}
int SDL_VoutSetBuffersGeometry(SDL_Vout *vout, int32_t width, int32_t height, int32_t format)
int SDL_LockYUVOverlay(SDL_Overlay *overlay)
{
/* FIXME: implement */
// FIXME: implement
return 0;
}
int SDL_VoutRender(SDL_Vout *vout, SDL_Picture *pic)
void SDL_UnlockYUVOverlay(SDL_Overlay *overlay)
{
/* FIXME: implement */
return 0;
// FIXME: implement
}
int SDL_VoutLockYUVPicture(SDL_Picture *pic)
int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect)
{
/* FIXME: implement */
// FIXME: implement
return 0;
}
int SDL_VoutUnlockYUVPicture(SDL_Picture *pic)
void SDL_FreeYUVOverlay(SDL_Overlay *overlay)
{
/* FIXME: implement */
return 0;
// FIXME: implement
}
/*****************************************************************************
* ijksdl_video.h
*****************************************************************************
*
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IJKSDL__IJKSDL_VIDEO_H
#define IJKSDL__IJKSDL_VIDEO_H
#include "ijksdl_stdinc.h"
/** @name Useful data types */
/*@{*/
typedef struct SDL_Rect {
Sint16 x, y;
Uint16 w, h;
} SDL_Rect;
typedef struct SDL_Color {
Uint8 r;
Uint8 g;
Uint8 b;
Uint8 unused;
} SDL_Color;
#define SDL_Colour SDL_Color
typedef struct SDL_Palette {
int ncolors;
SDL_Color *colors;
} SDL_Palette;
/*@}*/
/** Everything in the pixel format structure is read-only */
typedef struct SDL_PixelFormat {
SDL_Palette *palette;
Uint8 BitsPerPixel;
Uint8 BytesPerPixel;
Uint8 Rloss;
Uint8 Gloss;
Uint8 Bloss;
Uint8 Aloss;
Uint8 Rshift;
Uint8 Gshift;
Uint8 Bshift;
Uint8 Ashift;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
Uint32 Amask;
/** RGB color key information */
Uint32 colorkey;
/** Alpha value information (per-surface alpha) */
Uint8 alpha;
} SDL_PixelFormat;
/** This structure should be treated as read-only, except for 'pixels',
* which, if not NULL, contains the raw pixel data for the surface.
*/
typedef struct SDL_Surface {
Uint32 flags; /**< Read-only */
SDL_PixelFormat *format; /**< Read-only */
int w, h; /**< Read-only */
Uint16 pitch; /**< Read-only */
void *pixels; /**< Read-write */
int offset; /**< Private */
/** Hardware-specific surface info */
struct private_hwdata *hwdata;
/** clipping information */
SDL_Rect clip_rect; /**< Read-only */
Uint32 unused1; /**< for binary compatibility */
/** Allow recursive locks */
Uint32 locked; /**< Private */
/** info for fast blit mapping to other surfaces */
struct SDL_BlitMap *map; /**< Private */
/** format version, bumped at every change to invalidate blit maps */
unsigned int format_version; /**< Private */
/** Reference count -- used when freeing surface */
int refcount; /**< Read-mostly */
} SDL_Surface;
/** @name SDL_Surface Flags
* These are the currently supported flags for the SDL_surface
*/
/*@{*/
/** Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */
/*@{*/
#define SDL_SWSURFACE 0x00000000 /**< Surface is in system memory */
#define SDL_HWSURFACE 0x00000001 /**< Surface is in video memory */
#define SDL_ASYNCBLIT 0x00000004 /**< Use asynchronous blits if possible */
/*@}*/
/** Available for SDL_SetVideoMode() */
/*@{*/
#define SDL_ANYFORMAT 0x10000000 /**< Allow any video depth/pixel-format */
#define SDL_HWPALETTE 0x20000000 /**< Surface has exclusive palette */
#define SDL_DOUBLEBUF 0x40000000 /**< Set up double-buffered video mode */
#define SDL_FULLSCREEN 0x80000000 /**< Surface is a full screen display */
#define SDL_OPENGL 0x00000002 /**< Create an OpenGL rendering context */
#define SDL_OPENGLBLIT 0x0000000A /**< Create an OpenGL rendering context and use it for blitting */
#define SDL_RESIZABLE 0x00000010 /**< This video mode may be resized */
#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */
/*@}*/
/** Used internally (read-only) */
/*@{*/
#define SDL_HWACCEL 0x00000100 /**< Blit uses hardware acceleration */
#define SDL_SRCCOLORKEY 0x00001000 /**< Blit uses a source color key */
#define SDL_RLEACCELOK 0x00002000 /**< Private flag */
#define SDL_RLEACCEL 0x00004000 /**< Surface is RLE encoded */
#define SDL_SRCALPHA 0x00010000 /**< Blit uses source alpha blending */
#define SDL_PREALLOC 0x01000000 /**< Surface uses preallocated memory */
/*@}*/
/*@}*/
/** @name Overlay Formats
* The most common video overlay formats.
* For an explanation of these pixel formats, see:
* http://www.webartz.com/fourcc/indexyuv.htm
*
* For information on the relationship between color spaces, see:
* http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
*/
/*@{*/
#define SDL_YV12_OVERLAY 0x32315659 /**< Planar mode: Y + V + U (3 planes) */
#define SDL_IYUV_OVERLAY 0x56555949 /**< Planar mode: Y + U + V (3 planes) */
#define SDL_YUY2_OVERLAY 0x32595559 /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
#define SDL_UYVY_OVERLAY 0x59565955 /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
#define SDL_YVYU_OVERLAY 0x55595659 /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
/*@}*/
/** The YUV hardware video overlay */
typedef struct SDL_Overlay {
Uint32 format; /**< Read-only */
int w, h; /**< Read-only */
int planes; /**< Read-only */
Uint16 *pitches; /**< Read-only */
Uint8 **pixels; /**< Read-write */
/** @name Hardware-specific surface info */
/*@{*/
struct private_yuvhwfuncs *hwfuncs;
struct private_yuvhwdata *hwdata;
/*@{*/
/** @name Special flags */
/*@{*/
Uint32 hw_overlay :1; /**< Flag: This overlay hardware accelerated? */
Uint32 UnusedBits :31;
/*@}*/
} SDL_Overlay;
void SDL_FreeSurface(SDL_Surface *surface);
SDL_Overlay *SDL_CreateYUVOverlay(int width, int height,
Uint32 format, SDL_Surface *display);
SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags);
int SDL_LockYUVOverlay(SDL_Overlay *overlay);
void SDL_UnlockYUVOverlay(SDL_Overlay *overlay);
int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect);
void SDL_FreeYUVOverlay(SDL_Overlay *overlay);
#endif
/*****************************************************************************
* ijksdl_vout.h
*****************************************************************************
*
* copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IJKSDL__IJKSDL_VOUT_H
#define IJKSDL__IJKSDL_VOUT_H
#include "ijksdl_stdinc.h"
typedef struct SDL_Picture {
Uint32 format;
int w, h;
int planes;
Uint16 *pitches;
Uint8 **pixels;
} SDL_Picture;
typedef struct SDL_Vout
{
int32_t width;
int32_t height;
int32_t format;
} SDL_Vout;
SDL_Vout *SDL_VoutCreate();
void SDL_VoutFree(SDL_Vout *vout);
int SDL_VoutSetBuffersGeometry(SDL_Vout *vout, int32_t width, int32_t height, int32_t format);
int SDL_VoutRender(SDL_Vout *vout, SDL_Picture *pic);
int SDL_VoutLockYUVPicture(SDL_Picture *pic);
int SDL_VoutUnlockYUVPicture(SDL_Picture *pic);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册