Commit f5b927b3 authored by ramiro's avatar ramiro

Do not store a copy of AVFormatContext *s in vfw_ctx.

Save *s directly in SetWindowLongPtr instead.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@22574 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent a4c1db40
...@@ -38,7 +38,6 @@ struct vfw_ctx { ...@@ -38,7 +38,6 @@ struct vfw_ctx {
HANDLE mutex; HANDLE mutex;
HANDLE event; HANDLE event;
AVPacketList *pktl; AVPacketList *pktl;
AVFormatContext *s;
unsigned int curbufsize; unsigned int curbufsize;
unsigned int frame_num; unsigned int frame_num;
}; };
...@@ -150,15 +149,15 @@ static void dump_bih(AVFormatContext *s, BITMAPINFOHEADER *bih) ...@@ -150,15 +149,15 @@ static void dump_bih(AVFormatContext *s, BITMAPINFOHEADER *bih)
dstruct(s, bih, biClrImportant, "lu"); dstruct(s, bih, biClrImportant, "lu");
} }
static int shall_we_drop(struct vfw_ctx *ctx) static int shall_we_drop(AVFormatContext *s)
{ {
AVFormatContext *s = ctx->s; struct vfw_ctx *ctx = s->priv_data;
const uint8_t dropscore[] = {62, 75, 87, 100}; const uint8_t dropscore[] = {62, 75, 87, 100};
const int ndropscores = FF_ARRAY_ELEMS(dropscore); const int ndropscores = FF_ARRAY_ELEMS(dropscore);
unsigned int buffer_fullness = (ctx->curbufsize*100)/s->max_picture_buffer; unsigned int buffer_fullness = (ctx->curbufsize*100)/s->max_picture_buffer;
if(dropscore[++ctx->frame_num%ndropscores] <= buffer_fullness) { if(dropscore[++ctx->frame_num%ndropscores] <= buffer_fullness) {
av_log(ctx->s, AV_LOG_ERROR, av_log(s, AV_LOG_ERROR,
"real-time buffer %d%% full! frame dropped!\n", buffer_fullness); "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
return 1; return 1;
} }
...@@ -168,14 +167,16 @@ static int shall_we_drop(struct vfw_ctx *ctx) ...@@ -168,14 +167,16 @@ static int shall_we_drop(struct vfw_ctx *ctx)
static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr) static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
{ {
AVFormatContext *s;
struct vfw_ctx *ctx; struct vfw_ctx *ctx;
AVPacketList **ppktl, *pktl_next; AVPacketList **ppktl, *pktl_next;
ctx = (struct vfw_ctx *) GetWindowLongPtr(hwnd, GWLP_USERDATA); s = (AVFormatContext *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
ctx = s->priv_data;
dump_videohdr(ctx->s, vdhdr); dump_videohdr(s, vdhdr);
if(shall_we_drop(ctx)) if(shall_we_drop(s))
return FALSE; return FALSE;
WaitForSingleObject(ctx->mutex, INFINITE); WaitForSingleObject(ctx->mutex, INFINITE);
...@@ -243,8 +244,6 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -243,8 +244,6 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR(EIO); return AVERROR(EIO);
} }
ctx->s = s;
ctx->hwnd = capCreateCaptureWindow(NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0); ctx->hwnd = capCreateCaptureWindow(NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0);
if(!ctx->hwnd) { if(!ctx->hwnd) {
av_log(s, AV_LOG_ERROR, "Could not create capture window.\n"); av_log(s, AV_LOG_ERROR, "Could not create capture window.\n");
...@@ -271,7 +270,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -271,7 +270,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
goto fail_io; goto fail_io;
} }
SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) ctx); SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) s);
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
if(!st) { if(!st) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment