Difference between revisions of "Function:Decode"

From CUVI Wiki
(Created page with "__NOTOC__ JPEG Decoding: Decodes a JPEG file into an image pixel array. ===Function=== {| |style="font-size:150%;"| <syntaxhighlight lang="cpp"> CuviStatus decode(const Cuvi8u...")
 
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
===Function===
===Function===
{|
{|
|style="font-size:150%;"|
|style="font-size:100%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
CuviStatus decode(const Cuvi8u* src,
CuviStatus decode(const Cuvi8u* src,
Line 12: Line 12:
</syntaxhighlight>
</syntaxhighlight>
|}
|}


===Parameters===
===Parameters===
 
{|
|style="font-size:75%;"|
{|class="wikitable"
{|class="wikitable"
|-
|-
Line 41: Line 41:
| const CuviStream&
| const CuviStream&
| GPU stream ID for execution
| GPU stream ID for execution
|}
|}
 
|}
 


===Example===
===Example===
{|
{|
|style="font-size:150%;"|
|style="font-size:100%;"|
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">



Latest revision as of 18:23, 19 October 2022

JPEG Decoding: Decodes a JPEG file into an image pixel array.

Function

CuviStatus decode(const Cuvi8u* src,
                  const size_t srcBytes,
                  CuviImage& dst,
                  const bool srcOnGPU,
                  const CuviStream& stream = CuviStream());

Parameters

Name Type Description
src Cuvi8u* Pointer to encoded data
srcBytes const size_t Size of encoded data
dst CuviImage& dst Decoded image in CuviImage
srcOnGPU const bool Whether the encoded data is CPU pointer or GPU
stream const CuviStream& GPU stream ID for execution

Example

CuviImage img;

CuviStatus err = cuvi::codecs::decode(inputPath, img);

    if(err!= CUVI_SUCCESS)
    {
        cout <<"Failed to decode image, error: "<<err<<endl;
        return;
    }

cout<<"Decoded image dimensions: "<<img.width()<<"x"<<img.height()<<endl;
cout<<"Encoding image and writing to "<<outputPath<<endl;