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.

81 lines
2.5KB

  1. /*
  2. * Mpeg video formats-related defines and utility functions
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <stdint.h>
  21. #include "libavutil/common.h"
  22. #include "libavutil/frame.h"
  23. #include "libavutil/pixdesc.h"
  24. #include "avcodec.h"
  25. #include "mpegutils.h"
  26. void ff_draw_horiz_band(AVCodecContext *avctx,
  27. AVFrame *cur, AVFrame *last,
  28. int y, int h, int picture_structure,
  29. int first_field, int low_delay)
  30. {
  31. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
  32. int vshift = desc->log2_chroma_h;
  33. const int field_pic = picture_structure != PICT_FRAME;
  34. if (field_pic) {
  35. h <<= 1;
  36. y <<= 1;
  37. }
  38. h = FFMIN(h, avctx->height - y);
  39. if (field_pic && first_field &&
  40. !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
  41. return;
  42. if (avctx->draw_horiz_band) {
  43. AVFrame *src;
  44. int offset[AV_NUM_DATA_POINTERS];
  45. int i;
  46. if (cur->pict_type == AV_PICTURE_TYPE_B || low_delay ||
  47. (avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
  48. src = cur;
  49. else if (last)
  50. src = last;
  51. else
  52. return;
  53. if (cur->pict_type == AV_PICTURE_TYPE_B &&
  54. picture_structure == PICT_FRAME &&
  55. avctx->codec_id != AV_CODEC_ID_SVQ3) {
  56. for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
  57. offset[i] = 0;
  58. } else {
  59. offset[0]= y * src->linesize[0];
  60. offset[1]=
  61. offset[2]= (y >> vshift) * src->linesize[1];
  62. for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
  63. offset[i] = 0;
  64. }
  65. emms_c();
  66. avctx->draw_horiz_band(avctx, src, offset,
  67. y, picture_structure, h);
  68. }
  69. }