Converting FOUR_CHAR_CODE / FOURCC to string



  • I have an error handler that deals with FOUR_CHAR_CODE('xxxx') type of errors from a library.  The lib doesn't have any string definitions for the codes but I want to present something of the error in an arror message to aid tracking down errors.

    Are there any standard macros to convert a four cc back to a string as I'm thinking the endianness may be platform specifi?.  I can only find MAKEFOURCC in mmsystem.h to go from chars to fourcc.



  • [quote user="danio"]I have an error handler that deals with FOUR_CHAR_CODE('xxxx') type of errors from a library.  The lib doesn't have any string definitions for the codes but I want to present something of the error in an arror message to aid tracking down errors.

    Are there any standard macros to convert a four cc back to a string as I'm thinking the endianness may be platform specifi?.  I can only find MAKEFOURCC in mmsystem.h to go from chars to fourcc.
    [/quote]

    Wow... I just spent like 5 minutes going over the basics of FOURCCs because I thought you were asking something different lol... I left it below for others if they want to read.

     

    My advice: ignore endianess and just shift the damn bits. If you are only using it for an error message, then you'll know if endianess matters when someone gets an error message from a machine where the endianness is different than what you are using. 

     

    Each byte of the FOURCC should represent an ASCII character. You should simply use the FOURCC in the error code, as it would be strange to translate it. In AVI files, a FOURCC is used for the video codec for example. Some example of the values are "DIVX", "XVIG", "MJPG", "MP43", and so on. I believe FOURCCs are also used when requesting decompression to represent the desired ouput color format (same for compression and input color format). Examples of those FOURCCs would be "YV12", "YUY2", and probably something containing RGB. 


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.