Click here to Skip to main content
15,905,612 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Error when using libavcodec dll in vc++ Pin
RahulOP13-Jun-06 22:22
RahulOP13-Jun-06 22:22 
GeneralRe: Error when using libavcodec dll in vc++ Pin
RahulOP13-Jun-06 22:16
RahulOP13-Jun-06 22:16 
GeneralRe: Error when using libavcodec dll in vc++ Pin
Cedric Moonen13-Jun-06 22:27
Cedric Moonen13-Jun-06 22:27 
GeneralRe: Error when using libavcodec dll in vc++ Pin
RahulOP13-Jun-06 22:39
RahulOP13-Jun-06 22:39 
GeneralRe: Error when using libavcodec dll in vc++ Pin
Cedric Moonen13-Jun-06 23:14
Cedric Moonen13-Jun-06 23:14 
GeneralRe: Error when using libavcodec dll in vc++ [modified] Pin
RahulOP13-Jun-06 23:29
RahulOP13-Jun-06 23:29 
GeneralRe: Error when using libavcodec dll in vc++ Pin
RahulOP14-Jun-06 21:00
RahulOP14-Jun-06 21:00 
GeneralRe: Error when using libavcodec dll in vc++ Pin
Cedric Moonen15-Jun-06 1:24
Cedric Moonen15-Jun-06 1:24 
One thing you still didn't understand is that a line like as follow is completely wrong !!
codec=(AVCodec *)p3


Basically, p3 is a pointer to a function. The (AVCodec *) in front of it specifies that the pointer must in fact be interpreted as a pointer to a AVCodec structure. Which of course completely false. Please, take care of what I said previously !
If this function returns an AVCode pointer, then you should do this instead:
HMODULE hDll3 = LoadLibrary("avcodec.dll");
typedef (AVCode*)(avcodec_find_encoder)(int CODECID);
avcodec_find_encoder* p3 = (avcodec_find_encoder*)GetProcAddress(hDll3, "avcodec_find_encoder");
if(p3==NULL)
AfxMessageBox("Failed loading3");
p3(CODEC_ID_MPEG1VIDEO);
if(p3==NULL)
AfxMessageBox("Failed loading3");

// Call the function and get the result:
AVCodec* codec = p3(...);


Also, note that in the typedef, you specified that this function receive a integer parameter, so of course you need to supply it also (note the ... in the function call).

Next, I repeat it once again: don't call LoadLibrary multiple times for the same library, this is useless. And don't forget to call FreeLibrary after it.

For this:

RahulOP wrote:
p2((AVCodecContext *)p4,(AVCodec*)p3);


This is the same as above: you cannot cast pointer to functions this way !!. What you need to do, is call p4 (and store the result somewhere, then call p3 and store the result somewhere and finally, call p2 and giving the previous results):
AVCodecContext* pContext = p4();
AVCoded* pCoded = p3(...);    // Don't forget to pass a parameter

// You can modify pContext and pCodec before passing them to p2, of course

p2(pContext,pCoded);


If you have problems, please update all the code with the remarks I explained here before posting another question (otherwise, I will correct the same things over and over again). If you don't understand something, ask for more information (instead of blindly copy/pasting).

Hope this helps


Cédric Moonen
Software developer

Charting control
GeneralRe: Error when using libavcodec dll in vc++ Pin
RahulOP15-Jun-06 2:53
RahulOP15-Jun-06 2:53 
GeneralRe: Error when using libavcodec dll in vc++ Pin
Eytukan13-Jun-06 22:27
Eytukan13-Jun-06 22:27 
AnswerRe: Error when using libavcodec dll in vc++ Pin
Viorel.13-Jun-06 21:00
Viorel.13-Jun-06 21:00 
AnswerRe: Error when using libavcodec dll in vc++ Pin
Eytukan13-Jun-06 22:01
Eytukan13-Jun-06 22:01 
Question[Message Deleted] Pin
angelfirefox13-Jun-06 20:07
angelfirefox13-Jun-06 20:07 
AnswerRe: CTreeCtrl Height bright Display Pin
Sarath C13-Jun-06 20:35
Sarath C13-Jun-06 20:35 
AnswerRe: CTreeCtrl Height bright Display Pin
Hamid_RT13-Jun-06 20:47
Hamid_RT13-Jun-06 20:47 
QuestionRe: [Message Deleted] Pin
toxcct13-Jun-06 22:24
toxcct13-Jun-06 22:24 
AnswerRe: [Message Deleted] Pin
ThatsAlok13-Jun-06 22:44
ThatsAlok13-Jun-06 22:44 
QuestionCRichEditCtrl show gif [modified] Pin
chybin13-Jun-06 20:03
chybin13-Jun-06 20:03 
QuestionSet beginning of file? Pin
_johan13-Jun-06 20:02
_johan13-Jun-06 20:02 
AnswerRe: Set beginning of file? Pin
kakan13-Jun-06 20:08
professionalkakan13-Jun-06 20:08 
AnswerRe: Set beginning of file? Pin
Laxman Auti13-Jun-06 20:25
Laxman Auti13-Jun-06 20:25 
GeneralRe: Set beginning of file? Pin
_johan13-Jun-06 20:30
_johan13-Jun-06 20:30 
Questionhow to convert output of console based in VC++ to windows based in C++ .NET Pin
YogeshRT13-Jun-06 19:31
YogeshRT13-Jun-06 19:31 
AnswerRe: how to convert output of console based in VC++ to windows based in C++ .NET Pin
_AnsHUMAN_ 13-Jun-06 19:34
_AnsHUMAN_ 13-Jun-06 19:34 
Generalhow to handle unmanaged code from the managed code. Pin
YogeshRT13-Jun-06 19:47
YogeshRT13-Jun-06 19:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.