On Tue, Nov 24, 2009 at 12:49 AM, Jean-Daniel Dupas
<[email protected]> wrote:
>
> Le 24 nov. 2009 à 00:42, Ratin a écrit :
>
>> Jean-Daniel Dupas <devli...@...> writes:
>>
>>>
>>>
>>> Le 21 nov. 2009 à 10:28, Ratin a écrit :
>>>
>>>> Hi All, I am developing an app that opens multiple streams and read
>>>> data in threads and que in buffers, using avcodec as a demuxer, the
>>>> code is contained in one shared object module which is dynamically
>>>> loaded by the app (lets call it streamer module). I am then passing
>>>> the same AVFormatContexts to another shared object module that I load
>>>> dynamically by the app (lets say decoder module), to regain the
>>>> AVCodecContext from the AVFormatContexts and, open the codec to decode
>>>> whats in the queue.
>>>>
>>>> The problem I am having has to do with having codec open in both of
>>>> these modules, in the comments for the prototype of avcodec_open, it
>>>> states that this function is not thread safe.To me that means I cant
>>>> have two copies of codec opened with the same codec contexts in both
>>>> modules. If thats true, then what would be the best way to reopen a
>>>> codec which relates to the same codec context that I have opened on
>>>> the streamer module. I could probably pass around pointer to codec
>>>> itself but then how to get back the format contexts and avcontexts?
>>>>
>>>
>>> You can register a lock manager using av_lockmgr_register().
>>> This manager will be call in avcodec_open() and avcodec_close() to prevent
>> race condition.
>>>
>>
>> Thanks for your reply.
>>
>> My problem has to do with what pointers I should pass around so I can open 
>> the
>> right decoder.
>>
>> Is it possible to:
>>
>> 1. Open the stream with  av_open_input_file and av_find_stream_info (or
>> av_open_input_stream) which populates the codec context values based on 
>> whats on
>> the file
>> 2. Change the fields in returned codec context and call avcodec_find_decoder 
>> to
>> open HW accelerated decoder instead of what it finds by default?
>> avcodec_find_decoder doesn't return HW accelared decoder by default.
>>
>>
>
> AFAIK, you can freely change the fields as needed before opening the codec, 
> as long as it remains consistent with the file content (at least, fieldw 
> marked as 'set by user' in the AVCodecContext struct declaration).
>
> You can for example, set the AVCodecContext->get_format field before opening, 
> and returns an HW accelerated format from this callback (I don't know it this 
> is enough to use an HW codec though).
>
>
> -- Jean-Daniel
>

Hi Jean, yes I noticed that. I found a solution by passing the format
context from the streamer .so module, pass it to the decoder module,
find the codec context within it, then open a h264vdpau codec with the
codec context. This kept all the streaming related parameters intact
while openning the h264 vdpau decoder which I can use by overriding
functions like get_buffer, draw_horizontal_band etc. I just need to
make it all multithreaded now :)

Thanks for your ideas!

Ratin
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to