Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 10 mēnešiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef _hls_h264_h_
  2. #define _hls_h264_h_
  3. #include <inttypes.h>
  4. #include <stdint.h>
  5. #include <stddef.h>
  6. static inline const uint8_t* h264_startcode(const uint8_t *data, size_t bytes)
  7. {
  8. size_t i;
  9. for (i = 2; i + 1 < bytes; i++)
  10. {
  11. if (0x01 == data[i] && 0x00 == data[i - 1] && 0x00 == data[i - 2])
  12. return data + i + 1;
  13. }
  14. return NULL;
  15. }
  16. static inline uint8_t h264_idr(const uint8_t *data, size_t bytes)
  17. {
  18. uint8_t naltype;
  19. const uint8_t *p;
  20. do
  21. {
  22. p = h264_startcode(data, bytes);
  23. if (p)
  24. {
  25. naltype = p[0] & 0x1f;
  26. // 1: no-IDR slice
  27. // 2: A-slice
  28. // 3: B-slice
  29. // 4: C-slice
  30. // 5: IDR frame
  31. if (naltype > 0 && naltype < 6)
  32. {
  33. return 5 == naltype ? 1 : 0;
  34. }
  35. bytes -= p - data;
  36. data = p;
  37. }
  38. } while (p);
  39. return 0;
  40. }
  41. static inline int h265_irap(const uint8_t* p, size_t bytes)
  42. {
  43. size_t i;
  44. uint8_t type;
  45. for (i = 2; i + 1 < bytes; i++)
  46. {
  47. if (0x01 == p[i] && 0x00 == p[i - 1] && 0x00 == p[i - 2])
  48. {
  49. type = (p[i + 1] >> 1) & 0x3f;
  50. if (type < 32)
  51. return (16 <= type && type <= 23) ? 1 : 0;
  52. }
  53. }
  54. return 0;
  55. }
  56. #endif /* !_hls_h264_h_ */