mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Do not store a copy of AVFormatContext *s in vfw_ctx.
Save *s directly in SetWindowLongPtr instead. Originally committed as revision 22574 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
3922deb577
commit
ce03ed4df1
@ -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)
|
|||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
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)
|
|||||||
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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user