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.

131 lines
4.0KB

  1. /*
  2. * H.263i decoder
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "mpegvideo.h"
  21. /* don't understand why they choose a different header ! */
  22. int ff_intel_h263_decode_picture_header(MpegEncContext *s)
  23. {
  24. int format;
  25. /* picture header */
  26. if (get_bits_long(&s->gb, 22) != 0x20) {
  27. av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
  28. return -1;
  29. }
  30. s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
  31. if (get_bits1(&s->gb) != 1) {
  32. av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
  33. return -1; /* marker */
  34. }
  35. if (get_bits1(&s->gb) != 0) {
  36. av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
  37. return -1; /* h263 id */
  38. }
  39. skip_bits1(&s->gb); /* split screen off */
  40. skip_bits1(&s->gb); /* camera off */
  41. skip_bits1(&s->gb); /* freeze picture release off */
  42. format = get_bits(&s->gb, 3);
  43. if (format != 7) {
  44. av_log(s->avctx, AV_LOG_ERROR, "Intel H263 free format not supported\n");
  45. return -1;
  46. }
  47. s->h263_plus = 0;
  48. s->pict_type = FF_I_TYPE + get_bits1(&s->gb);
  49. s->unrestricted_mv = get_bits1(&s->gb);
  50. s->h263_long_vectors = s->unrestricted_mv;
  51. if (get_bits1(&s->gb) != 0) {
  52. av_log(s->avctx, AV_LOG_ERROR, "SAC not supported\n");
  53. return -1; /* SAC: off */
  54. }
  55. s->obmc= get_bits1(&s->gb);
  56. s->pb_frame = get_bits1(&s->gb);
  57. if(format == 7){
  58. format = get_bits(&s->gb, 3);
  59. if(format == 0 || format == 7){
  60. av_log(s->avctx, AV_LOG_ERROR, "Wrong Intel H263 format\n");
  61. return -1;
  62. }
  63. if(get_bits(&s->gb, 2))
  64. av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
  65. s->loop_filter = get_bits1(&s->gb);
  66. if(get_bits1(&s->gb))
  67. av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
  68. if(get_bits1(&s->gb))
  69. s->pb_frame = 2;
  70. if(get_bits(&s->gb, 5))
  71. av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
  72. if(get_bits(&s->gb, 5) != 1)
  73. av_log(s->avctx, AV_LOG_ERROR, "Invalid marker\n");
  74. }
  75. if(format == 6){
  76. int ar = get_bits(&s->gb, 4);
  77. skip_bits(&s->gb, 9); // display width
  78. skip_bits1(&s->gb);
  79. skip_bits(&s->gb, 9); // display height
  80. if(ar == 15){
  81. skip_bits(&s->gb, 8); // aspect ratio - width
  82. skip_bits(&s->gb, 8); // aspect ratio - height
  83. }
  84. }
  85. s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
  86. skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
  87. if(s->pb_frame){
  88. skip_bits(&s->gb, 3); //temporal reference for B-frame
  89. skip_bits(&s->gb, 2); //dbquant
  90. }
  91. /* PEI */
  92. while (get_bits1(&s->gb) != 0) {
  93. skip_bits(&s->gb, 8);
  94. }
  95. s->f_code = 1;
  96. s->y_dc_scale_table=
  97. s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
  98. ff_h263_show_pict_info(s);
  99. return 0;
  100. }
  101. AVCodec h263i_decoder = {
  102. "h263i",
  103. CODEC_TYPE_VIDEO,
  104. CODEC_ID_H263I,
  105. sizeof(MpegEncContext),
  106. ff_h263_decode_init,
  107. NULL,
  108. ff_h263_decode_end,
  109. ff_h263_decode_frame,
  110. CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
  111. .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"),
  112. .pix_fmts= ff_pixfmt_list_420,
  113. };