Mercurial > libavcodec.hg
comparison mpegvideo.c @ 239:16cd8a9c4da4 libavcodec
- Minor changes on bitrate control
| author | pulento |
|---|---|
| date | Fri, 15 Feb 2002 20:46:37 +0000 |
| parents | 5fc0c3af3fe4 |
| children | 3860331a1ecb |
comparison
equal
deleted
inserted
replaced
| 238:99a9f903f0e3 | 239:16cd8a9c4da4 |
|---|---|
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 if (s->encoding) { | 151 if (s->encoding) { |
| 152 /* Allocate MB type table */ | 152 /* Allocate MB type table */ |
| 153 s->mb_type = malloc(s->mb_num * sizeof(char)); | 153 s->mb_type = av_mallocz(s->mb_num * sizeof(char)); |
| 154 if (s->mb_type == NULL) { | 154 if (s->mb_type == NULL) { |
| 155 perror("malloc"); | 155 perror("malloc"); |
| 156 goto fail; | 156 goto fail; |
| 157 } | 157 } |
| 158 | 158 |
| 159 s->mb_var = av_mallocz(s->mb_num * sizeof(INT16)); | |
| 160 if (s->mb_var == NULL) { | |
| 161 perror("malloc"); | |
| 162 goto fail; | |
| 163 } | |
| 159 /* Allocate MV table */ | 164 /* Allocate MV table */ |
| 160 /* By now we just have one MV per MB */ | 165 /* By now we just have one MV per MB */ |
| 161 s->mv_table[0] = malloc(s->mb_num * sizeof(INT16)); | 166 s->mv_table[0] = av_mallocz(s->mb_num * sizeof(INT16)); |
| 162 s->mv_table[1] = malloc(s->mb_num * sizeof(INT16)); | 167 s->mv_table[1] = av_mallocz(s->mb_num * sizeof(INT16)); |
| 163 if (s->mv_table[1] == NULL || s->mv_table[0] == NULL) { | 168 if (s->mv_table[1] == NULL || s->mv_table[0] == NULL) { |
| 164 perror("malloc"); | 169 perror("malloc"); |
| 165 goto fail; | 170 goto fail; |
| 166 } | 171 } |
| 167 } | 172 } |
| 223 s->context_initialized = 1; | 228 s->context_initialized = 1; |
| 224 return 0; | 229 return 0; |
| 225 fail: | 230 fail: |
| 226 if (s->mb_type) | 231 if (s->mb_type) |
| 227 free(s->mb_type); | 232 free(s->mb_type); |
| 233 if (s->mb_var) | |
| 234 free(s->mb_var); | |
| 228 if (s->mv_table[0]) | 235 if (s->mv_table[0]) |
| 229 free(s->mv_table[0]); | 236 free(s->mv_table[0]); |
| 230 if (s->mv_table[1]) | 237 if (s->mv_table[1]) |
| 231 free(s->mv_table[1]); | 238 free(s->mv_table[1]); |
| 232 if (s->motion_val) | 239 if (s->motion_val) |
| 257 { | 264 { |
| 258 int i; | 265 int i; |
| 259 | 266 |
| 260 if (s->mb_type) | 267 if (s->mb_type) |
| 261 free(s->mb_type); | 268 free(s->mb_type); |
| 269 if (s->mb_var) | |
| 270 free(s->mb_var); | |
| 262 if (s->mv_table[0]) | 271 if (s->mv_table[0]) |
| 263 free(s->mv_table[0]); | 272 free(s->mv_table[0]); |
| 264 if (s->mv_table[1]) | 273 if (s->mv_table[1]) |
| 265 free(s->mv_table[1]); | 274 free(s->mv_table[1]); |
| 266 if (s->motion_val) | 275 if (s->motion_val) |
| 1077 sub_pixels_2(s->block[4], ptr, s->linesize >> 1, dxy); | 1086 sub_pixels_2(s->block[4], ptr, s->linesize >> 1, dxy); |
| 1078 ptr = s->last_picture[2] + offset; | 1087 ptr = s->last_picture[2] + offset; |
| 1079 sub_pixels_2(s->block[5], ptr, s->linesize >> 1, dxy); | 1088 sub_pixels_2(s->block[5], ptr, s->linesize >> 1, dxy); |
| 1080 } | 1089 } |
| 1081 emms_c(); | 1090 emms_c(); |
| 1082 | 1091 //if (s->avg_mb_var) |
| 1092 // printf("\nqscale=%2d dquant=%2d var=%4d avgvar=%4d", s->qscale, | |
| 1093 // s->qscale*(s->mb_var[s->mb_width*mb_y+mb_x]/s->avg_mb_var), | |
| 1094 // s->mb_var[s->mb_width*mb_y+mb_x], s->avg_mb_var); | |
| 1083 /* DCT & quantize */ | 1095 /* DCT & quantize */ |
| 1084 if (s->h263_msmpeg4) { | 1096 if (s->h263_msmpeg4) { |
| 1085 msmpeg4_dc_scale(s); | 1097 msmpeg4_dc_scale(s); |
| 1086 } else if (s->h263_pred) { | 1098 } else if (s->h263_pred) { |
| 1087 h263_dc_scale(s); | 1099 h263_dc_scale(s); |
