* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "avformat.h"
+#include "libavformat/avformat.h"
#include <vfw.h>
#include <windows.h>
switch(biCompression) {
case MKTAG('Y', 'U', 'Y', '2'):
return PIX_FMT_YUYV422;
+ case MKTAG('I', '4', '2', '0'):
+ return PIX_FMT_YUV420P;
case BI_RGB:
switch(biBitCount) { /* 1-8 are untested */
case 1:
const int ndropscores = sizeof(dropscore)/sizeof(dropscore[0]);
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,
"real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
return 1;
(LPARAM) videostream_cb);
if(!ret) {
av_log(s, AV_LOG_ERROR, "Could not set video stream callback.\n");
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) ctx);
/* Set video format */
bisize = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
- if(!bisize) {
- vfw_read_close(s);
- return AVERROR_IO;
- }
+ if(!bisize)
+ goto fail_io;
bi = av_malloc(bisize);
if(!bi) {
vfw_read_close(s);
return AVERROR_NOMEM;
}
ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
- if(!ret) {
- av_free(bi);
- vfw_read_close(s);
- return AVERROR_IO;
- }
+ if(!ret)
+ goto fail_bi;
dump_bih(s, &bi->bmiHeader);
bi->bmiHeader.biWidth = width ;
bi->bmiHeader.biHeight = height;
+#if 0
+ /* For testing yet unsupported compressions
+ * Copy these values from user-supplied verbose information */
+ bi->bmiHeader.biWidth = 320;
+ bi->bmiHeader.biHeight = 240;
+ bi->bmiHeader.biPlanes = 1;
+ bi->bmiHeader.biBitCount = 12;
+ bi->bmiHeader.biCompression = MKTAG('I','4','2','0');
+ bi->bmiHeader.biSizeImage = 115200;
+ dump_bih(s, &bi->bmiHeader);
+#endif
+
ret = SendMessage(ctx->hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
if(!ret) {
av_log(s, AV_LOG_ERROR, "Could not set Video Format.\n");
- av_free(bi);
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_bi;
}
biCompression = bi->bmiHeader.biCompression;
/* Set sequence setup */
ret = SendMessage(ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP, sizeof(cparms),
(LPARAM) &cparms);
- if(!ret) {
- vfw_read_close(s);
- return AVERROR_IO;
- }
+ if(!ret)
+ goto fail_io;
dump_captureparms(s, &cparms);
ret = SendMessage(ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP, sizeof(cparms),
(LPARAM) &cparms);
- if(!ret) {
- vfw_read_close(s);
- return AVERROR_IO;
- }
+ if(!ret)
+ goto fail_io;
codec = st->codec;
codec->time_base = ap->time_base;
ctx->mutex = CreateMutex(NULL, 0, NULL);
if(!ctx->mutex) {
av_log(s, AV_LOG_ERROR, "Could not create Mutex.\n" );
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
ctx->event = CreateEvent(NULL, 1, 0, NULL);
if(!ctx->event) {
av_log(s, AV_LOG_ERROR, "Could not create Event.\n" );
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
ret = SendMessage(ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
if(!ret) {
av_log(s, AV_LOG_ERROR, "Could not start capture sequence.\n" );
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
return 0;
+
+fail_bi:
+ av_free(bi);
+
+fail_io:
+ vfw_read_close(s);
+ return AVERROR_IO;
}
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt)