# Transcode was not successful

**URL:** <https://forums.imgtec.com/t/transcode-was-not-successful/3331>\
**Category:** PowerVR Insider\
**Tags:** pvrtextool\
**Created:** [January 10, 2021, 12:50am UTC](https://forums.imgtec.com/t/transcode-was-not-successful/3331 "2021-01-10T00:50:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![onepiecefreak](https://avatars.discourse-cdn.com/v4/letter/o/f6c823/32.png) [@onepiecefreak](https://forums.imgtec.com/u/onepiecefreak)\
**Post date:** [January 10, 2021, 12:50am UTC](https://forums.imgtec.com/t/transcode-was-not-successful/3331/1 "2021-01-10T00:50:32Z")

</div>

Following my initial and first problem with PVRTexTool here: [PVRTexLib in C# (with C++ tests)](https://forums.imgtec.com/t/pvrtexlib-in-c-with-c-tests/3329)  
I come across another problem separate to the one linked above.

I try to transcode an image from RGBA8888 to R8. This has no special meaning and is meant to serve as an example for me to learn how I set up the transcoder options.

I currently set up my options like this:

```
PVRTexLib_TranscoderOptions* CreateOptions()
{
    auto options = new PVRTexLib_TranscoderOptions();

    options->sizeofStruct = 0x2c;
    options->doDither = false;
    options->colourspace = PVRTexLibColourSpace::PVRTLCS_Linear;
    options->maxRange = 1;
    options->pixelFormat = PVRTexLibPixelFormat::R8;
    options->quality = PVRTexLibCompressorQuality::PVRTLCQ_PVRTCHigh;

    options->channelType[0] = { PVRTexLibVariableType::PVRTLVT_UnsignedByte };
    options->channelType[1] = { PVRTexLibVariableType::PVRTLVT_UnsignedByte };
    options->channelType[2] = { PVRTexLibVariableType::PVRTLVT_UnsignedByte };
    options->channelType[3] = { PVRTexLibVariableType::PVRTLVT_UnsignedByte };

    return options;
}

```

The PixelFormat R8 is setup as the value 0x0000000861626772, which defines the rgba encoding, where only the R channel is defined with 8 bits. This could already be a potential problem in why the Transcode may fail.

I would like someone to tell me if the options are correctly set up like this on first glance. I will reply with my full sample application code.

---

<div class="post-metadata">

**Author:** ![onepiecefreak](https://avatars.discourse-cdn.com/v4/letter/o/f6c823/32.png) [@onepiecefreak](https://forums.imgtec.com/u/onepiecefreak)\
**Post date:** [January 10, 2021, 12:54am UTC](https://forums.imgtec.com/t/transcode-was-not-successful/3331/2 "2021-01-10T00:54:47Z")

</div>

```
int main()
{
    auto data = new char[16*4];
    for (int i = 0; i < 16*4; i++)
        data[i] = 0;

    auto attribs = CreateParams();
    auto header = PVRTexLib_CreateTextureHeader(attribs);
    auto texture = PVRTexLib_CreateTexture(header, data);

    // Transcode texture
    auto options = CreateOptions(); // See CreateOptions method in my initial post
    auto successful = PVRTexLib_TranscodeTexture(texture, *options);
}

PVRHeader_CreateParams* CreateParams()
{
    PVRHeader_CreateParams* params = new PVRHeader_CreateParams();

    params->width = 4;
    params->height = 4;
    params->depth = 1;

    // Setting to zero means library will not use and/or print height/width information
    params->numMipMaps = 1;

    // Additionally to numMipMaps, if any of the number values is 0, PVRTexLib_GetTextureDataPtr will return 0
    params->numArrayMembers = 1;
    params->numFaces = 1;
    params->pixelFormat = PVRTexLibPixelFormat::RGBA8888;
    params->colourSpace = PVRTexLibColourSpace::PVRTLCS_Linear;
    params->channelType = PVRTexLibVariableType::PVRTLVT_UnsignedByte;
    params->preMultiplied = false;

    return params;
}

```

R8 is set up as 0x0000000861626772.  
RGBA8888 is set up as 0x0808080861626772.

---

<div class="post-metadata">

**Author:** ![AlejandroC](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@AlejandroC](https://forums.imgtec.com/u/AlejandroC)\
**Post date:** [January 11, 2021, 9:50am UTC](https://forums.imgtec.com/t/transcode-was-not-successful/3331/3 "2021-01-11T09:50:36Z")

</div>

Hi onepiecefreak,

Thanks for your interest in PVRTexTool. I’ll forward your questions to the Tools Team and come back to you shortly.

Best regards,  
Alejandro

---

<div class="post-metadata">

**Author:** ![AlejandroC](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@AlejandroC](https://forums.imgtec.com/u/AlejandroC)\
**Post date:** [January 11, 2021, 1:13pm UTC](https://forums.imgtec.com/t/transcode-was-not-successful/3331/4 "2021-01-11T13:13:05Z")

</div>

Hi onepiecefreak,

The Tools Team has reviewed your issue.

The call to **PVRTexLib\_TranscodeTexture** is failing due to passing the pixel format with a named channel (R/G/B/A) with a bit width of 0, which is not supported.

You have two options here:  
1. Use the correct encoding for **R8** which is **0x800000072**.  
2. Use the macro **PVRTGENPIXELID** defined in **PVRTexLibDefines.h** to create uncompressed pixel format IDs in a more straightforward way.

Best regards,  
Alejandro

---

<div class="post-metadata">

**Author:** ![onepiecefreak](https://avatars.discourse-cdn.com/v4/letter/o/f6c823/32.png) [@onepiecefreak](https://forums.imgtec.com/u/onepiecefreak)\
**Post date:** [January 11, 2021, 6:36pm UTC](https://forums.imgtec.com/t/transcode-was-not-successful/3331/5 "2021-01-11T18:36:20Z")

</div>

Oh, interesting. I thought I had to always give all color components and then just set their bit depth to zero, if they are not needed.

Thanks for the tip with the **PVRTGENPIXELID** macro. I will try that out and report back.

---

<div class="post-metadata">

**Author:** ![onepiecefreak](https://avatars.discourse-cdn.com/v4/letter/o/f6c823/32.png) [@onepiecefreak](https://forums.imgtec.com/u/onepiecefreak)\
**Post date:** [January 11, 2021, 8:41pm UTC](https://forums.imgtec.com/t/transcode-was-not-successful/3331/6 "2021-01-11T20:41:09Z")

</div>

Yes, that worked. Thank you.

---

<div class="post-metadata">

**Author:** ![AlejandroC](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@AlejandroC](https://forums.imgtec.com/u/AlejandroC)\
**Post date:** [January 12, 2021, 10:45am UTC](https://forums.imgtec.com/t/transcode-was-not-successful/3331/7 "2021-01-12T10:45:30Z")

</div>

Hi onepiecefreak,

Glad it worked, please come back if you have more questions.

Best regards,  
Alejandro
