|
8 | 8 | * be found in the AUTHORS file in the root of the source tree. |
9 | 9 | */ |
10 | 10 |
|
| 11 | +#include <assert.h> |
11 | 12 | #include <limits.h> |
12 | 13 | #include <stdint.h> |
13 | 14 | #include <stdlib.h> |
@@ -396,8 +397,7 @@ static vpx_codec_err_t set_vp8e_config(VP8_CONFIG *oxcf, |
396 | 397 | if (mr_cfg) { |
397 | 398 | oxcf->mr_total_resolutions = mr_cfg->mr_total_resolutions; |
398 | 399 | oxcf->mr_encoder_id = mr_cfg->mr_encoder_id; |
399 | | - oxcf->mr_down_sampling_factor.num = mr_cfg->mr_down_sampling_factor.num; |
400 | | - oxcf->mr_down_sampling_factor.den = mr_cfg->mr_down_sampling_factor.den; |
| 400 | + oxcf->mr_down_sampling_factor = mr_cfg->mr_down_sampling_factor; |
401 | 401 | oxcf->mr_low_res_mode_info = mr_cfg->mr_low_res_mode_info; |
402 | 402 | } |
403 | 403 | #else |
@@ -667,11 +667,22 @@ static vpx_codec_err_t vp8e_mr_alloc_mem(const vpx_codec_enc_cfg_t *cfg, |
667 | 667 | } |
668 | 668 | #else |
669 | 669 | (void)cfg; |
670 | | - (void)mem_loc; |
| 670 | + *mem_loc = NULL; |
671 | 671 | #endif |
672 | 672 | return res; |
673 | 673 | } |
674 | 674 |
|
| 675 | +static void vp8e_mr_free_mem(void *mem_loc) { |
| 676 | +#if CONFIG_MULTI_RES_ENCODING |
| 677 | + LOWER_RES_FRAME_INFO *shared_mem_loc = (LOWER_RES_FRAME_INFO *)mem_loc; |
| 678 | + free(shared_mem_loc->mb_info); |
| 679 | + free(mem_loc); |
| 680 | +#else |
| 681 | + (void)mem_loc; |
| 682 | + assert(!mem_loc); |
| 683 | +#endif |
| 684 | +} |
| 685 | + |
675 | 686 | static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx, |
676 | 687 | vpx_codec_priv_enc_mr_cfg_t *mr_cfg) { |
677 | 688 | vpx_codec_err_t res = VPX_CODEC_OK; |
@@ -754,10 +765,7 @@ static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx) { |
754 | 765 | /* Free multi-encoder shared memory */ |
755 | 766 | if (ctx->oxcf.mr_total_resolutions > 0 && |
756 | 767 | (ctx->oxcf.mr_encoder_id == ctx->oxcf.mr_total_resolutions - 1)) { |
757 | | - LOWER_RES_FRAME_INFO *shared_mem_loc = |
758 | | - (LOWER_RES_FRAME_INFO *)ctx->oxcf.mr_low_res_mode_info; |
759 | | - free(shared_mem_loc->mb_info); |
760 | | - free(ctx->oxcf.mr_low_res_mode_info); |
| 768 | + vp8e_mr_free_mem(ctx->oxcf.mr_low_res_mode_info); |
761 | 769 | } |
762 | 770 | #endif |
763 | 771 |
|
@@ -1431,5 +1439,6 @@ CODEC_INTERFACE(vpx_codec_vp8_cx) = { |
1431 | 1439 | NULL, |
1432 | 1440 | vp8e_get_preview, |
1433 | 1441 | vp8e_mr_alloc_mem, |
| 1442 | + vp8e_mr_free_mem, |
1434 | 1443 | } /* encoder functions */ |
1435 | 1444 | }; |
0 commit comments