Skip to content

Commit

Permalink
fix decoding of version number
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Feb 1, 2023
1 parent 8572909 commit cc62a50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dec265/dec265.cc
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ int main(int argc, char** argv)

if (optind != argc-1 || show_help) {
fprintf(stderr," dec265 v%s\n", de265_get_version());
fprintf(stderr,"--------------\n");
fprintf(stderr,"-----------------\n");
fprintf(stderr,"usage: dec265 [options] videofile.bin\n");
fprintf(stderr,"The video file must be a raw bitstream, or a stream with NAL units (option -n).\n");
fprintf(stderr,"\n");
Expand Down
11 changes: 8 additions & 3 deletions libde265/de265.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,24 @@ LIBDE265_API uint32_t de265_get_version_number(void)
return (LIBDE265_NUMERIC_VERSION);
}

static uint8_t bcd2dec(uint8_t v)
{
return (v>>4) * 10 + (v & 0x0F);
}

LIBDE265_API int de265_get_version_number_major(void)
{
return ((LIBDE265_NUMERIC_VERSION)>>24) & 0xFF;
return bcd2dec(((LIBDE265_NUMERIC_VERSION)>>24) & 0xFF);
}

LIBDE265_API int de265_get_version_number_minor(void)
{
return ((LIBDE265_NUMERIC_VERSION)>>16) & 0xFF;
return bcd2dec(((LIBDE265_NUMERIC_VERSION)>>16) & 0xFF);
}

LIBDE265_API int de265_get_version_number_maintenance(void)
{
return ((LIBDE265_NUMERIC_VERSION)>>8) & 0xFF;
return bcd2dec(((LIBDE265_NUMERIC_VERSION)>>8) & 0xFF);
}


Expand Down
4 changes: 4 additions & 0 deletions libde265/de265.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ extern "C" {

// version of linked libde265 library
LIBDE265_API const char *de265_get_version(void);

// returns the version number as a BCD number.
// 0xAABBCCDD is interpreted as version AA.BB.CC.
// For example: 0x02143000 is version 2.14.30
LIBDE265_API uint32_t de265_get_version_number(void);

LIBDE265_API int de265_get_version_number_major(void);
Expand Down

0 comments on commit cc62a50

Please sign in to comment.