input_frame_validation_vp9.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # HG changeset patch
  2. # User Randell Jesup <rjesup@jesup.org>
  3. # Parent 87841f3bfc9d99a37e31cd43b2e2d03c325af84f
  4. Bug 1315288: Add input checks for VP9 r=rillian
  5. diff --git a/media/libvpx/vp8/vp8_cx_iface.c b/media/libvpx/vp8/vp8_cx_iface.c
  6. --- a/media/libvpx/vp8/vp8_cx_iface.c
  7. +++ b/media/libvpx/vp8/vp8_cx_iface.c
  8. @@ -917,17 +917,17 @@ static vpx_codec_err_t vp8e_encode(vpx_c
  9. dst_time_stamp = pts * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den;
  10. dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den;
  11. if (img != NULL)
  12. {
  13. res = image2yuvconfig(img, &sd);
  14. if (sd.y_width != ctx->cfg.g_w || sd.y_height != ctx->cfg.g_h) {
  15. - /* from vp8_encoder.h for g_w/g_h:
  16. + /* from vpx_encoder.h for g_w/g_h:
  17. "Note that the frames passed as input to the encoder must have this resolution"
  18. */
  19. ctx->base.err_detail = "Invalid input frame resolution";
  20. res = VPX_CODEC_INVALID_PARAM;
  21. } else {
  22. if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags,
  23. &sd, dst_time_stamp, dst_end_time_stamp))
  24. {
  25. diff --git a/media/libvpx/vp9/vp9_cx_iface.c b/media/libvpx/vp9/vp9_cx_iface.c
  26. --- a/media/libvpx/vp9/vp9_cx_iface.c
  27. +++ b/media/libvpx/vp9/vp9_cx_iface.c
  28. @@ -989,21 +989,29 @@ static vpx_codec_err_t encoder_encode(vp
  29. // Set up internal flags
  30. if (ctx->base.init_flags & VPX_CODEC_USE_PSNR)
  31. cpi->b_calculate_psnr = 1;
  32. if (img != NULL) {
  33. res = image2yuvconfig(img, &sd);
  34. - // Store the original flags in to the frame buffer. Will extract the
  35. - // key frame flag when we actually encode this frame.
  36. - if (vp9_receive_raw_frame(cpi, flags | ctx->next_frame_flags,
  37. - &sd, dst_time_stamp, dst_end_time_stamp)) {
  38. - res = update_error_state(ctx, &cpi->common.error);
  39. + if (sd.y_width != ctx->cfg.g_w || sd.y_height != ctx->cfg.g_h) {
  40. + /* from vpx_encoder.h for g_w/g_h:
  41. + "Note that the frames passed as input to the encoder must have this resolution"
  42. + */
  43. + ctx->base.err_detail = "Invalid input frame resolution";
  44. + res = VPX_CODEC_INVALID_PARAM;
  45. + } else {
  46. + // Store the original flags in to the frame buffer. Will extract the
  47. + // key frame flag when we actually encode this frame.
  48. + if (vp9_receive_raw_frame(cpi, flags | ctx->next_frame_flags,
  49. + &sd, dst_time_stamp, dst_end_time_stamp)) {
  50. + res = update_error_state(ctx, &cpi->common.error);
  51. + }
  52. }
  53. ctx->next_frame_flags = 0;
  54. }
  55. cx_data = ctx->cx_data;
  56. cx_data_sz = ctx->cx_data_sz;
  57. /* Any pending invisible frames? */