1
0

mkv_f263_decoder.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #include "mkv_f263_decoder.h"
  2. #include "lib.h"
  3. int MKVDecoderCreator::CreateVideoDecoder(const char *codec_id, const nsmkv::TrackEntryData *track_entry_data, const nsmkv::VideoData *video_data, ifc_mkvvideodecoder **decoder)
  4. {
  5. if (!strcmp(codec_id, "V_MS/VFW/FOURCC"))
  6. {
  7. if (track_entry_data->codec_private && track_entry_data->codec_private_len)
  8. {
  9. const BITMAPINFOHEADER *header = (const BITMAPINFOHEADER *)track_entry_data->codec_private;
  10. if (header->biCompression == '1VLF')
  11. {
  12. void *ctx = F263_CreateDecoder();
  13. *decoder = new MKVFLV1(ctx);
  14. return CREATEDECODER_SUCCESS;
  15. }
  16. }
  17. return CREATEDECODER_NOT_MINE;
  18. }
  19. else
  20. {
  21. return CREATEDECODER_NOT_MINE;
  22. }
  23. }
  24. #define CBCLASS MKVDecoderCreator
  25. START_DISPATCH;
  26. CB(CREATE_VIDEO_DECODER, CreateVideoDecoder)
  27. END_DISPATCH;
  28. #undef CBCLASS
  29. MKVFLV1::MKVFLV1(void *ctx) : decoder(ctx)
  30. {
  31. }
  32. int MKVFLV1::GetOutputProperties(int *x, int *y, int *color_format, double *aspect_ratio)
  33. {
  34. if (width && height)
  35. {
  36. *x = width;
  37. *y = height;
  38. *color_format = '21VY';
  39. *aspect_ratio=1.0;
  40. return MKV_SUCCESS;
  41. }
  42. return MKV_FAILURE;
  43. }
  44. int MKVFLV1::DecodeBlock(const void *inputBuffer, size_t inputBufferBytes, uint64_t timestamp)
  45. {
  46. last_timestamp = (int32_t)timestamp;
  47. int keyframe;
  48. int ret = F263_DecodeFrame(decoder, const_cast<void *>(inputBuffer), inputBufferBytes, &yv12, &width, &height, &keyframe);
  49. if (ret == F263_OK)
  50. {
  51. decoded=1;
  52. return MKV_SUCCESS;
  53. }
  54. else
  55. return MKV_FAILURE;
  56. }
  57. void MKVFLV1::Flush()
  58. {
  59. }
  60. int MKVFLV1::GetPicture(void **data, void **decoder_data, uint64_t *timestamp)
  61. {
  62. if (decoded)
  63. {
  64. *timestamp = last_timestamp;
  65. *decoder_data = 0;
  66. *data = &yv12;
  67. decoded=0;
  68. return MKV_SUCCESS;
  69. }
  70. return MKV_FAILURE;
  71. }
  72. #define CBCLASS MKVFLV1
  73. START_DISPATCH;
  74. CB(GET_OUTPUT_PROPERTIES, GetOutputProperties)
  75. CB(DECODE_BLOCK, DecodeBlock)
  76. VCB(FLUSH, Flush)
  77. CB(GET_PICTURE, GetPicture)
  78. END_DISPATCH;
  79. #undef CBCLASS