AudioSample.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef NULLSOFT_IN_MP4_AUDIOSAMPLE_H
  2. #define NULLSOFT_IN_MP4_AUDIOSAMPLE_H
  3. #include "main.h"
  4. class AudioSample
  5. {
  6. public:
  7. AudioSample(size_t maxInput, size_t maxOutput)
  8. {
  9. input = (unsigned __int8 *)calloc(maxInput, sizeof(unsigned __int8));
  10. inputSize = maxInput;
  11. output = (__int8 *)calloc(maxOutput, sizeof(__int8));
  12. outputSize = maxOutput;
  13. inputValid = outputValid = result = sampleRate = numChannels =
  14. bitsPerSample = bitrate = sampleId = timestamp = duration = offset = 0;
  15. outputCursor = 0;
  16. }
  17. ~AudioSample()
  18. {
  19. free(output);
  20. free(input);
  21. }
  22. bool OK()
  23. {
  24. return input && output;
  25. }
  26. // input
  27. unsigned __int8 *input;
  28. size_t inputSize, inputValid;
  29. MP4SampleId sampleId;
  30. // output
  31. __int8 *output, *outputCursor;
  32. size_t outputSize, outputValid;
  33. MP4Duration duration, offset, timestamp;
  34. int result;
  35. unsigned int sampleRate, numChannels, bitsPerSample;
  36. unsigned int bitrate;
  37. };
  38. class VideoSample
  39. {
  40. public:
  41. VideoSample(size_t maxInput)
  42. {
  43. input = (unsigned __int8 *)calloc(maxInput, sizeof(unsigned __int8));
  44. inputSize = maxInput;
  45. timestamp = inputValid = 0;
  46. }
  47. ~VideoSample()
  48. {
  49. free(input);
  50. }
  51. bool OK()
  52. {
  53. return !!input;
  54. }
  55. // input
  56. unsigned __int8 *input;
  57. size_t inputSize, inputValid;
  58. MP4Timestamp timestamp;
  59. };
  60. class DecodedVideoSample
  61. {
  62. public:
  63. ~DecodedVideoSample()
  64. {
  65. decoder->FreePicture(output,decoder_data);
  66. }
  67. void *output;
  68. void *decoder_data;
  69. MP4VideoDecoder *decoder;
  70. MP4Timestamp timestamp;
  71. };
  72. #endif