Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 22nd November 2002, 22:36   #1  |  Link
R3g
Registered User
 
Join Date: Nov 2001
Location: Reims, France
Posts: 75
How does vfw store codec settings

Well I just put my nose in all these vfw things, and I wonder how codec settings work.
I explain : when you call ICCompressorChoose and the user sets up his codec, you get a COMPVAR structure, which, I think, can't handle codec-specific settings.
So I suppose that vfw, or maybe the codec itself, stores these settings somewhere, and then retrieve it when it's time to encode ?

Does anybody have precision about how it works ?
__________________
Kick me, I'm dumb !
R3g is offline   Reply With Quote
Old 23rd November 2002, 00:05   #2  |  Link
mandm
Registered User
 
mandm's Avatar
 
Join Date: Jun 2002
Location: Italy
Posts: 35
Thank to Int21h...

and if you search the ICGetStateSize in the MSDN help you'll find other samples


void SaveCodecParams(const char* filename, COMPVARS* cvar)
{
LONG lStateSize = 0;
void* memState = NULL;
FILE* fileState = fopen(filename,"wb");

lStateSize = ICGetStateSize(cvar->hic);
memState = malloc(lStateSize);
if (ICGetState(cvar->hic, memState, lStateSize) < 0)
{
_RPTF0(_CRT_WARN,"\tSaveCodecParams\tError ICGetState\n");
return;
}

fwrite(&cvar->fccHandler, sizeof(cvar->fccHandler), 1, fileState);
fwrite(&cvar->lKey, sizeof(cvar->lKey), 1, fileState);
fwrite(&cvar->lQ, sizeof(cvar->lQ), 1, fileState);
fwrite(&cvar->lDataRate, sizeof(cvar->lDataRate), 1, fileState);
fwrite(&lStateSize, sizeof(lStateSize), 1, fileState);
fwrite(memState, lStateSize, 1, fileState);
free(memState);

fclose(fileState);
}

void LoadCodecParams(void)
{
int NbPassFile = 0;
FILE* fileState;

if ((fileState = fopen("M&M Avi 1.par", "r")) != NULL)
ReadCodecParam(fileState, pcompvars); // Read 1st pass codec state
else
ZeroMemory(pcompvars,sizeof(COMPVARS));


if ((fileState = fopen("M&M Avi 2.par", "r")) != NULL)
ReadCodecParam(fileState, pcompvars2); // Read 2st pass codec state
else
ZeroMemory(pcompvars2,sizeof(COMPVARS));
}
__________________
M&M MPEG Manipulator
mandm@mail.com
Home of M&M the MPEG manipulator
mandm is offline   Reply With Quote
Old 23rd November 2002, 00:06   #3  |  Link
mandm
Registered User
 
mandm's Avatar
 
Join Date: Jun 2002
Location: Italy
Posts: 35
Thank to Int21h...

and if you search the ICGetStateSize in the MSDN help you'll find other samples


void SaveCodecParams(const char* filename, COMPVARS* cvar)
{
LONG lStateSize = 0;
void* memState = NULL;
FILE* fileState = fopen(filename,"wb");

lStateSize = ICGetStateSize(cvar->hic);
memState = malloc(lStateSize);
if (ICGetState(cvar->hic, memState, lStateSize) < 0)
{
_RPTF0(_CRT_WARN,"\tSaveCodecParams\tError ICGetState\n");
return;
}

fwrite(&cvar->fccHandler, sizeof(cvar->fccHandler), 1, fileState);
fwrite(&cvar->lKey, sizeof(cvar->lKey), 1, fileState);
fwrite(&cvar->lQ, sizeof(cvar->lQ), 1, fileState);
fwrite(&cvar->lDataRate, sizeof(cvar->lDataRate), 1, fileState);
fwrite(&lStateSize, sizeof(lStateSize), 1, fileState);
fwrite(memState, lStateSize, 1, fileState);
free(memState);

fclose(fileState);
}

void LoadCodecParams(void)
{
int NbPassFile = 0;
FILE* fileState;

if ((fileState = fopen("M&M Avi 1.par", "r")) != NULL)
ReadCodecParam(fileState, pcompvars); // Read 1st pass codec state
else
ZeroMemory(pcompvars,sizeof(COMPVARS));


if ((fileState = fopen("M&M Avi 2.par", "r")) != NULL)
ReadCodecParam(fileState, pcompvars2); // Read 2st pass codec state
else
ZeroMemory(pcompvars2,sizeof(COMPVARS));
}


M&M
__________________
M&M MPEG Manipulator
mandm@mail.com
Home of M&M the MPEG manipulator
mandm is offline   Reply With Quote
Old 23rd November 2002, 01:04   #4  |  Link
[Toff]
Registered User
 
Join Date: Oct 2001
Location: FRANCE
Posts: 320
Re: How does vfw store codec settings

Quote:
Originally posted by R3g
So I suppose that vfw, or maybe the codec itself, stores these settings somewhere, and then retrieve it when it's time to encode ?
Does anybody have precision about how it works ?
If you look into the COMPVARS struct you see the 2 interesting fields :
LPVOID lpState;
LONG cbState;

lpState is a pointer to the codec parameters struct.
Each codec has is own struct.

//---------------

In the codec there is :

typedef struct {
int : bitrate;
...
} mycodec_params_type;

mycodec_params_type codec_params;

// ----------------

In the application you could see :

compvar.lpState = &codec_params;
compvar.cbState = sizeof(mycodec_params);

So if you have the source of the codec, like for xvid you can easily retrieve parameters. (look at the CONFIG struct in config.h of the vfw xvid module)
But if the codec change, your application will be broken ...
__________________
Regards [Toff]
[Toff] is offline   Reply With Quote
Old 23rd November 2002, 15:28   #5  |  Link
R3g
Registered User
 
Join Date: Nov 2001
Location: Reims, France
Posts: 75
Ok, thanks, I misunderstood a couple of things before, it is much simplier than I thought.
__________________
Kick me, I'm dumb !
R3g is offline   Reply With Quote
Old 25th November 2002, 12:14   #6  |  Link
mandm
Registered User
 
mandm's Avatar
 
Join Date: Jun 2002
Location: Italy
Posts: 35
Online there is the code (1.1 beta) that saves and reloads the plugin settings.

Only it looks like it does not work so well.


If you are able to work with save/load of dual pass plugins can you help me ?


M&M
__________________
M&M MPEG Manipulator
mandm@mail.com
Home of M&M the MPEG manipulator
mandm is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 16:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.