You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

H264LibavDecoderContext.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright (C) 2021 Vladimir Sukhonosov <xornet@xornet.org>
  2. * Copyright (C) 2021 Martins Mozeiko <martins.mozeiko@gmail.com>
  3. * All Rights Reserved.
  4. *
  5. * This is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This software is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this software; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  18. * USA.
  19. */
  20. #ifndef __RFB_H264LIBAVDECODER_H__
  21. #define __RFB_H264LIBAVDECODER_H__
  22. extern "C" {
  23. #include <libavcodec/avcodec.h>
  24. #include <libswscale/swscale.h>
  25. }
  26. #include <rfb/H264DecoderContext.h>
  27. namespace rfb {
  28. class H264LibavDecoderContext : public H264DecoderContext {
  29. public:
  30. H264LibavDecoderContext(const Rect &r) : H264DecoderContext(r) {}
  31. ~H264LibavDecoderContext() { freeCodec(); }
  32. virtual void decode(const rdr::U8* h264_buffer, rdr::U32 len,
  33. ModifiablePixelBuffer* pb);
  34. protected:
  35. virtual bool initCodec();
  36. virtual void freeCodec();
  37. private:
  38. rdr::U8* makeH264WorkBuffer(const rdr::U8* buffer, rdr::U32 len);
  39. AVCodecContext *avctx;
  40. AVCodecParserContext *parser;
  41. AVFrame* frame;
  42. SwsContext* sws;
  43. uint8_t* swsBuffer;
  44. rdr::U8* h264WorkBuffer;
  45. rdr::U32 h264WorkBufferLength;
  46. };
  47. }
  48. #endif