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.

66 lines
2.0KB

  1. /*
  2. * Alias PIX image demuxer
  3. * Copyright (c) 2014 Michael Niedermayer
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "img2.h"
  22. #include "libavcodec/bytestream.h"
  23. static int brender_read_probe(AVProbeData *p)
  24. {
  25. const uint8_t *b = p->buf;
  26. const uint8_t *end = b + p->buf_size;
  27. int width = bytestream_get_be16(&b);
  28. int height = bytestream_get_be16(&b);
  29. av_unused int ox = bytestream_get_be16(&b);
  30. av_unused int oy = bytestream_get_be16(&b);
  31. int bpp = bytestream_get_be16(&b);
  32. int x, y;
  33. if (!width || !height)
  34. return 0;
  35. if (bpp != 24 && bpp != 8)
  36. return 0;
  37. for (y=0; y<2 && y<height; y++) {
  38. for (x=0; x<width; ) {
  39. int count = *b++;
  40. if (count == 0 || x + count > width)
  41. return 0;
  42. if (b > end)
  43. return AVPROBE_SCORE_MAX / 8;
  44. b += bpp / 8;
  45. x += count;
  46. }
  47. }
  48. return AVPROBE_SCORE_EXTENSION + 1;
  49. }
  50. AVInputFormat ff_image2_alias_pix_demuxer = {
  51. .name = "alias_pix",
  52. .long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"),
  53. .priv_data_size = sizeof(VideoDemuxData),
  54. .read_probe = brender_read_probe,
  55. .read_header = ff_img_read_header,
  56. .read_packet = ff_img_read_packet,
  57. .raw_codec_id = AV_CODEC_ID_ALIAS_PIX,
  58. };