Do not free BITMAPINFOHEADER before we are done using it.
Fixes trac ticket #396.
Completely untested.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
(cherry picked from commit 177aec1257
)
This commit is contained in:

committed by
Michael Niedermayer

parent
30442fa217
commit
9c96b1efb1
@@ -242,7 +242,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
AVStream *st;
|
AVStream *st;
|
||||||
int devnum;
|
int devnum;
|
||||||
int bisize;
|
int bisize;
|
||||||
BITMAPINFO *bi;
|
BITMAPINFO *bi = NULL;
|
||||||
CAPTUREPARMS cparms;
|
CAPTUREPARMS cparms;
|
||||||
DWORD biCompression;
|
DWORD biCompression;
|
||||||
WORD biBitCount;
|
WORD biBitCount;
|
||||||
@@ -293,7 +293,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
(LPARAM) videostream_cb);
|
(LPARAM) videostream_cb);
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
av_log(s, AV_LOG_ERROR, "Could not set video stream callback.\n");
|
av_log(s, AV_LOG_ERROR, "Could not set video stream callback.\n");
|
||||||
goto fail_io;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) s);
|
SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) s);
|
||||||
@@ -307,7 +307,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
/* Set video format */
|
/* Set video format */
|
||||||
bisize = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
|
bisize = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
|
||||||
if(!bisize)
|
if(!bisize)
|
||||||
goto fail_io;
|
goto fail;
|
||||||
bi = av_malloc(bisize);
|
bi = av_malloc(bisize);
|
||||||
if(!bi) {
|
if(!bi) {
|
||||||
vfw_read_close(s);
|
vfw_read_close(s);
|
||||||
@@ -315,7 +315,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
}
|
}
|
||||||
ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
|
ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
|
||||||
if(!ret)
|
if(!ret)
|
||||||
goto fail_bi;
|
goto fail;
|
||||||
|
|
||||||
dump_bih(s, &bi->bmiHeader);
|
dump_bih(s, &bi->bmiHeader);
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
ret = av_parse_video_size(&bi->bmiHeader.biWidth, &bi->bmiHeader.biHeight, ctx->video_size);
|
ret = av_parse_video_size(&bi->bmiHeader.biWidth, &bi->bmiHeader.biHeight, ctx->video_size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n");
|
av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n");
|
||||||
goto fail_bi;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if FF_API_FORMAT_PARAMETERS
|
#if FF_API_FORMAT_PARAMETERS
|
||||||
@@ -349,19 +349,17 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
ret = SendMessage(ctx->hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
|
ret = SendMessage(ctx->hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
av_log(s, AV_LOG_ERROR, "Could not set Video Format.\n");
|
av_log(s, AV_LOG_ERROR, "Could not set Video Format.\n");
|
||||||
goto fail_bi;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
biCompression = bi->bmiHeader.biCompression;
|
biCompression = bi->bmiHeader.biCompression;
|
||||||
biBitCount = bi->bmiHeader.biBitCount;
|
biBitCount = bi->bmiHeader.biBitCount;
|
||||||
|
|
||||||
av_free(bi);
|
|
||||||
|
|
||||||
/* Set sequence setup */
|
/* Set sequence setup */
|
||||||
ret = SendMessage(ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP, sizeof(cparms),
|
ret = SendMessage(ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP, sizeof(cparms),
|
||||||
(LPARAM) &cparms);
|
(LPARAM) &cparms);
|
||||||
if(!ret)
|
if(!ret)
|
||||||
goto fail_io;
|
goto fail;
|
||||||
|
|
||||||
dump_captureparms(s, &cparms);
|
dump_captureparms(s, &cparms);
|
||||||
|
|
||||||
@@ -376,7 +374,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
ret = SendMessage(ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP, sizeof(cparms),
|
ret = SendMessage(ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP, sizeof(cparms),
|
||||||
(LPARAM) &cparms);
|
(LPARAM) &cparms);
|
||||||
if(!ret)
|
if(!ret)
|
||||||
goto fail_io;
|
goto fail;
|
||||||
|
|
||||||
codec = st->codec;
|
codec = st->codec;
|
||||||
codec->time_base = (AVRational){fps.den, fps.num};
|
codec->time_base = (AVRational){fps.den, fps.num};
|
||||||
@@ -405,31 +403,31 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
av_freep(&bi);
|
||||||
|
|
||||||
av_set_pts_info(st, 32, 1, 1000);
|
av_set_pts_info(st, 32, 1, 1000);
|
||||||
|
|
||||||
ctx->mutex = CreateMutex(NULL, 0, NULL);
|
ctx->mutex = CreateMutex(NULL, 0, NULL);
|
||||||
if(!ctx->mutex) {
|
if(!ctx->mutex) {
|
||||||
av_log(s, AV_LOG_ERROR, "Could not create Mutex.\n" );
|
av_log(s, AV_LOG_ERROR, "Could not create Mutex.\n" );
|
||||||
goto fail_io;
|
goto fail;
|
||||||
}
|
}
|
||||||
ctx->event = CreateEvent(NULL, 1, 0, NULL);
|
ctx->event = CreateEvent(NULL, 1, 0, NULL);
|
||||||
if(!ctx->event) {
|
if(!ctx->event) {
|
||||||
av_log(s, AV_LOG_ERROR, "Could not create Event.\n" );
|
av_log(s, AV_LOG_ERROR, "Could not create Event.\n" );
|
||||||
goto fail_io;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SendMessage(ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
|
ret = SendMessage(ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
av_log(s, AV_LOG_ERROR, "Could not start capture sequence.\n" );
|
av_log(s, AV_LOG_ERROR, "Could not start capture sequence.\n" );
|
||||||
goto fail_io;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail_bi:
|
fail:
|
||||||
av_free(bi);
|
av_freep(&bi);
|
||||||
|
|
||||||
fail_io:
|
|
||||||
vfw_read_close(s);
|
vfw_read_close(s);
|
||||||
return AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user