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.

69 lines
2.3KB

  1. /*
  2. * RAW AVS3-P2/IEEE1857.10 video demuxer
  3. * Copyright (c) 2020 Zhenyu Wang <wangzhenyu@pkusz.edu.cn>
  4. * Bingjie Han <hanbj@pkusz.edu.cn>
  5. * Huiwen Ren <hwrenx@gmail.com>
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #include "libavcodec/avs3.h"
  24. #include "libavcodec/internal.h"
  25. #include "avformat.h"
  26. #include "rawdec.h"
  27. static int avs3video_probe(const AVProbeData *p)
  28. {
  29. const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
  30. uint32_t code = -1;
  31. uint8_t state = 0;
  32. int pic = 0, seq = 0, slice_pos = 0;
  33. int ret = 0;
  34. while (ptr < end) {
  35. ptr = avpriv_find_start_code(ptr, end, &code);
  36. state = code & 0xFF;
  37. if ((code & 0xFFFFFF00) == 0x100) {
  38. if (state < AVS3_SEQ_START_CODE) {
  39. if (code < slice_pos)
  40. return 0;
  41. slice_pos = code;
  42. } else {
  43. slice_pos = 0;
  44. }
  45. if (state == AVS3_SEQ_START_CODE) {
  46. seq++;
  47. if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != AVS3_PROFILE_BASELINE_MAIN10)
  48. return 0;
  49. } else if (AVS3_ISPIC(state)) {
  50. pic++;
  51. } else if ((state == AVS3_UNDEF_START_CODE) ||
  52. (state > AVS3_VIDEO_EDIT_CODE)) {
  53. return 0;
  54. }
  55. }
  56. }
  57. if (seq && pic && av_match_ext(p->filename, "avs3")) {
  58. ret = AVPROBE_SCORE_MAX;
  59. }
  60. return ret;
  61. }
  62. FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, "avs3", AV_CODEC_ID_AVS3)