Guest User

Untitled

a guest
May 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.69 KB | None | 0 0
  1. diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
  2. index e0b240a..adbb32c 100644
  3. --- a/modules/demux/mp4/libmp4.c
  4. +++ b/modules/demux/mp4/libmp4.c
  5. @@ -33,6 +33,7 @@
  6.  
  7.  #include "libmp4.h"
  8.  #include "drms.h"
  9. +#include <math.h>
  10.  
  11.  /*****************************************************************************
  12.   * Here are defined some macro to make life simpler but before using it
  13. @@ -633,16 +634,34 @@ static int MP4_ReadBox_tkhd(  stream_t *p_stream, MP4_Box_t *p_box )
  14.      for( unsigned i = 0; i < 9; i++ )
  15.      {
  16.          MP4_GET4BYTES( p_box->data.p_tkhd->i_matrix[i] );
  17. +        if (i != 8)
  18. +            p_box->data.p_tkhd->i_matrix[i] /= 65536;
  19.      }
  20.      MP4_GET4BYTES( p_box->data.p_tkhd->i_width );
  21. -    MP4_GET4BYTES( p_box->data.p_tkhd->i_height );
  22. +    MP4_GET4BYTES( p_box->data.p_tkhd->i_height );    
  23. +
  24. +    double rotation;    //angle in degrees to be rotated clockwise
  25. +    double scale[2];    // scale factor; sx = scale[0] , sy = scale[1]
  26. +    double translate[2];// amount to translate; tx = translate[0] , ty = translate[1]
  27. +    
  28. +    int *matrix = p_box->data.p_tkhd->i_matrix;
  29. +    
  30. +    translate[0] = (double)matrix[6];
  31. +    translate[1] = (double)matrix[7];
  32. +    
  33. +    scale[0] = sqrt(matrix[0] * matrix[0] +
  34. +                    matrix[3] * matrix[3]);
  35. +    scale[1] = sqrt(matrix[1] * matrix[1] +
  36. +                    matrix[4] * matrix[4]);
  37. +    
  38. +    rotation = atan2(matrix[1] / scale[1], matrix[0] / scale[0]) * 180 / acos(-1);
  39.  
  40.  #ifdef MP4_VERBOSE
  41.      MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mvhd->i_creation_time );
  42.      MP4_ConvertDate2Str( s_modification_time, p_box->data.p_mvhd->i_modification_time );
  43.      MP4_ConvertDate2Str( s_duration, p_box->data.p_mvhd->i_duration );
  44.  
  45. -    msg_Dbg( p_stream, "read box: \"tkhd\" creation %s modification %s duration %s track ID %d layer %d volume %f width %f height %f. "
  46. +    msg_Dbg( p_stream, "read box: \"tkhd\" creation %s modification %s duration %s track ID %d layer %d volume %f rotation %f scaleX %f scaleY %f width %f height %f. "
  47.              "Matrix: %i %i %i %i %i %i %i %i %i",
  48.                    s_creation_time,
  49.                    s_modification_time,
  50. @@ -650,6 +669,9 @@ static int MP4_ReadBox_tkhd(  stream_t *p_stream, MP4_Box_t *p_box )
  51.                    p_box->data.p_tkhd->i_track_ID,
  52.                    p_box->data.p_tkhd->i_layer,
  53.                    (float)p_box->data.p_tkhd->i_volume / 256 ,
  54. +                  rotation,
  55. +                  scale[0],
  56. +                  scale[1],
  57.                    (float)p_box->data.p_tkhd->i_width / 65536,
  58.                    (float)p_box->data.p_tkhd->i_height / 65536,
  59.                    p_box->data.p_tkhd->i_matrix[0],
Add Comment
Please, Sign In to add comment