Revision ce03ed4d libavdevice/vfwcap.c

View differences:

libavdevice/vfwcap.c
38 38
    HANDLE mutex;
39 39
    HANDLE event;
40 40
    AVPacketList *pktl;
41
    AVFormatContext *s;
42 41
    unsigned int curbufsize;
43 42
    unsigned int frame_num;
44 43
};
......
150 149
    dstruct(s, bih, biClrImportant, "lu");
151 150
}
152 151

  
153
static int shall_we_drop(struct vfw_ctx *ctx)
152
static int shall_we_drop(AVFormatContext *s)
154 153
{
155
    AVFormatContext *s = ctx->s;
154
    struct vfw_ctx *ctx = s->priv_data;
156 155
    const uint8_t dropscore[] = {62, 75, 87, 100};
157 156
    const int ndropscores = FF_ARRAY_ELEMS(dropscore);
158 157
    unsigned int buffer_fullness = (ctx->curbufsize*100)/s->max_picture_buffer;
159 158

  
160 159
    if(dropscore[++ctx->frame_num%ndropscores] <= buffer_fullness) {
161
        av_log(ctx->s, AV_LOG_ERROR,
160
        av_log(s, AV_LOG_ERROR,
162 161
              "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
163 162
        return 1;
164 163
    }
......
168 167

  
169 168
static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
170 169
{
170
    AVFormatContext *s;
171 171
    struct vfw_ctx *ctx;
172 172
    AVPacketList **ppktl, *pktl_next;
173 173

  
174
    ctx = (struct vfw_ctx *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
174
    s = (AVFormatContext *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
175
    ctx = s->priv_data;
175 176

  
176
    dump_videohdr(ctx->s, vdhdr);
177
    dump_videohdr(s, vdhdr);
177 178

  
178
    if(shall_we_drop(ctx))
179
    if(shall_we_drop(s))
179 180
        return FALSE;
180 181

  
181 182
    WaitForSingleObject(ctx->mutex, INFINITE);
......
243 244
        return AVERROR(EIO);
244 245
    }
245 246

  
246
    ctx->s = s;
247

  
248 247
    ctx->hwnd = capCreateCaptureWindow(NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0);
249 248
    if(!ctx->hwnd) {
250 249
        av_log(s, AV_LOG_ERROR, "Could not create capture window.\n");
......
271 270
        goto fail_io;
272 271
    }
273 272

  
274
    SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) ctx);
273
    SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) s);
275 274

  
276 275
    st = av_new_stream(s, 0);
277 276
    if(!st) {

Also available in: Unified diff