提交 38e40dfa 编写于 作者: Z Zhang Rui

ijksdl: fix incorrect memset

上级 775b5e79
...@@ -110,6 +110,7 @@ static SDL_VoutSurface *vout_set_video_mode(SDL_Vout *vout, int w, int h, int bp ...@@ -110,6 +110,7 @@ static SDL_VoutSurface *vout_set_video_mode(SDL_Vout *vout, int w, int h, int bp
static void vout_copy_image_yv12(ANativeWindow_Buffer *out_buffer, const SDL_VoutOverlay *overlay) static void vout_copy_image_yv12(ANativeWindow_Buffer *out_buffer, const SDL_VoutOverlay *overlay)
{ {
SDLTRACE("SDL_VoutAndroid: vout_copy_image_yv12(%p)", overlay);
assert(overlay->format == SDL_YV12_OVERLAY); assert(overlay->format == SDL_YV12_OVERLAY);
assert(overlay->planes == 3); assert(overlay->planes == 3);
...@@ -145,6 +146,7 @@ static void vout_copy_image_yv12(ANativeWindow_Buffer *out_buffer, const SDL_Vou ...@@ -145,6 +146,7 @@ static void vout_copy_image_yv12(ANativeWindow_Buffer *out_buffer, const SDL_Vou
static int voud_display_overlay_l(SDL_Vout *vout, SDL_VoutOverlay *overlay) static int voud_display_overlay_l(SDL_Vout *vout, SDL_VoutOverlay *overlay)
{ {
SDLTRACE("SDL_VoutAndroid: display(%p)", overlay);
SDL_Vout_Opaque *opaque = vout->opaque; SDL_Vout_Opaque *opaque = vout->opaque;
ANativeWindow *native_window = opaque->native_window; ANativeWindow *native_window = opaque->native_window;
int curr_w, curr_h, curr_format; int curr_w, curr_h, curr_format;
......
...@@ -38,7 +38,7 @@ inline static SDL_Vout *SDL_Vout_CreateInternal(size_t opaque_size) ...@@ -38,7 +38,7 @@ inline static SDL_Vout *SDL_Vout_CreateInternal(size_t opaque_size)
free(vout); free(vout);
return NULL; return NULL;
} }
memset(vout->opaque, 0, sizeof(vout->opaque)); memset(vout->opaque, 0, opaque_size);
vout->mutex = SDL_CreateMutex(); vout->mutex = SDL_CreateMutex();
if (vout->mutex == NULL) { if (vout->mutex == NULL) {
...@@ -76,7 +76,7 @@ inline static SDL_VoutOverlay *SDL_VoutOverlay_CreateInternal(size_t opaque_size ...@@ -76,7 +76,7 @@ inline static SDL_VoutOverlay *SDL_VoutOverlay_CreateInternal(size_t opaque_size
free(overlay); free(overlay);
return NULL; return NULL;
} }
memset(overlay->opaque, 0, sizeof(overlay->opaque)); memset(overlay->opaque, 0, opaque_size);
return overlay; return overlay;
} }
...@@ -92,4 +92,6 @@ inline static void SDL_VoutOverlay_FreeInternal(SDL_VoutOverlay *overlay) ...@@ -92,4 +92,6 @@ inline static void SDL_VoutOverlay_FreeInternal(SDL_VoutOverlay *overlay)
free(overlay); free(overlay);
} }
#define SDLTRACE ALOGW
#endif #endif
...@@ -62,6 +62,7 @@ static AVFrame *alloc_avframe(SDL_VoutOverlay_Opaque* opaque, enum AVPixelFormat ...@@ -62,6 +62,7 @@ static AVFrame *alloc_avframe(SDL_VoutOverlay_Opaque* opaque, enum AVPixelFormat
static void overlay_free_l(SDL_VoutOverlay *overlay) static void overlay_free_l(SDL_VoutOverlay *overlay)
{ {
ALOGE("SDL_Overlay(ffmpeg): overlay_free_l(%p)", overlay);
if (!overlay) if (!overlay)
return; return;
...@@ -109,9 +110,13 @@ static int overlay_unlock(SDL_VoutOverlay *overlay) ...@@ -109,9 +110,13 @@ static int overlay_unlock(SDL_VoutOverlay *overlay)
SDL_VoutOverlay *SDL_VoutCreateFFmpegYUVOverlay(int width, int height, Uint32 format, SDL_Vout *display) SDL_VoutOverlay *SDL_VoutCreateFFmpegYUVOverlay(int width, int height, Uint32 format, SDL_Vout *display)
{ {
SDLTRACE("SDL_VoutCreateFFmpegYUVOverlay(w=%d, h=%d, fmt=%.4s(0x%x, dp=%p)",
width, height, (const char*) &format, format, display);
SDL_VoutOverlay *overlay = SDL_VoutOverlay_CreateInternal(sizeof(SDL_VoutOverlay_Opaque)); SDL_VoutOverlay *overlay = SDL_VoutOverlay_CreateInternal(sizeof(SDL_VoutOverlay_Opaque));
if (!overlay) if (!overlay) {
ALOGE("SDL_VoutCreateFFmpegYUVOverlay(...)=NULL");
return NULL; return NULL;
}
overlay->format = format; overlay->format = format;
...@@ -123,17 +128,21 @@ SDL_VoutOverlay *SDL_VoutCreateFFmpegYUVOverlay(int width, int height, Uint32 fo ...@@ -123,17 +128,21 @@ SDL_VoutOverlay *SDL_VoutCreateFFmpegYUVOverlay(int width, int height, Uint32 fo
AVPicture *pic = NULL; AVPicture *pic = NULL;
switch (format) { switch (format) {
case SDL_YV12_OVERLAY: case SDL_YV12_OVERLAY:
SDLTRACE("SDL_VoutCreateFFmpegYUVOverlay(...): SDL_YV12_OVERLAY (swap UV)");
frame = alloc_avframe(opaque, AV_PIX_FMT_YUV420P, width, height); frame = alloc_avframe(opaque, AV_PIX_FMT_YUV420P, width, height);
overlay_fill(overlay, frame, format, 3); if (frame) {
/* swap U,V */ overlay_fill(overlay, frame, format, 3);
pic = (AVPicture *) frame; /* swap U,V */
overlay->pixels[2] = pic->data[1]; pic = (AVPicture *) frame;
overlay->pixels[1] = pic->data[2]; overlay->pixels[2] = pic->data[1];
overlay->pixels[1] = pic->data[2];
overlay->pitches[2] = pic->linesize[1];
overlay->pitches[1] = pic->linesize[2]; overlay->pitches[2] = pic->linesize[1];
overlay->pitches[1] = pic->linesize[2];
}
break; break;
default: default:
ALOGE("SDL_VoutCreateFFmpegYUVOverlay(...): unknown format");
break; break;
} }
...@@ -148,5 +157,6 @@ SDL_VoutOverlay *SDL_VoutCreateFFmpegYUVOverlay(int width, int height, Uint32 fo ...@@ -148,5 +157,6 @@ SDL_VoutOverlay *SDL_VoutCreateFFmpegYUVOverlay(int width, int height, Uint32 fo
overlay = NULL; overlay = NULL;
} }
SDLTRACE("SDL_VoutCreateFFmpegYUVOverlay(...)=%p", overlay);
return overlay; return overlay;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册