Showing the changes to libavcodec (4 of 4 files). Show all
Unified · Split
| @@ -28,12 +28,11 @@ · 27 unmodified lines | ||
| 28 | 28 | * huffyuv codec for libavcodec. |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | +#include <stddef.h> | |
| 31 | 32 | #include <stdint.h> |
| 32 | 33 | |
| 33 | −#include "libavutil/attributes.h" | |
| 34 | −#include "libavutil/error.h" | |
| 35 | 34 | #include "libavutil/log.h" |
| 36 | −#include "libavutil/mem.h" | |
| 35 | +#include "libavutil/macros.h" | |
| 37 | 36 | |
| 38 | 37 | #include "huffyuv.h" |
| 39 | 38 | |
| @@ -59,26 +58,3 @@ int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int · 19 unmodified lines | ||
| 59 | 58 | } |
| 60 | 59 | return 0; |
| 61 | 60 | } |
| 62 | − | |
| 63 | −av_cold int ff_huffyuv_alloc_temp(uint8_t *temp[3], uint16_t *temp16[3], int width) | |
| 64 | −{ | |
| 65 | − int i; | |
| 66 | − | |
| 67 | − for (i=0; i<3; i++) { | |
| 68 | − temp[i] = av_malloc(4 * width + 16); | |
| 69 | − if (!temp[i]) | |
| 70 | − return AVERROR(ENOMEM); | |
| 71 | − temp16[i] = (uint16_t*)temp[i]; | |
| 72 | − } | |
| 73 | − return 0; | |
| 74 | −} | |
| 75 | − | |
| 76 | −av_cold void ff_huffyuv_common_end(uint8_t *temp[3], uint16_t *temp16[3]) | |
| 77 | −{ | |
| 78 | − int i; | |
| 79 | − | |
| 80 | − for(i = 0; i < 3; i++) { | |
| 81 | − av_freep(&temp[i]); | |
| 82 | − temp16[i] = NULL; | |
| 83 | − } | |
| 84 | −} | |
| @@ -55,8 +55,6 @@ typedef enum Predictor { · 54 unmodified lines | ||
| 55 | 55 | MEDIAN, |
| 56 | 56 | } Predictor; |
| 57 | 57 | |
| 58 | −void ff_huffyuv_common_end(uint8_t *temp[3], uint16_t *temp16[3]); | |
| 59 | −int ff_huffyuv_alloc_temp(uint8_t *temp[3], uint16_t *temp16[3], int width); | |
| 60 | 58 | int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n); |
| 61 | 59 | |
| 62 | 60 | #endif /* AVCODEC_HUFFYUV_H */ |
| @@ -323,7 +323,11 @@ static av_cold int decode_end(AVCodecContext *avctx) · 322 unmodified lines | ||
| 323 | 323 | HYuvDecContext *s = avctx->priv_data; |
| 324 | 324 | int i; |
| 325 | 325 | |
| 326 | − ff_huffyuv_common_end(s->temp, s->temp16); | |
| 326 | + for (int i = 0; i < 3; i++) { | |
| 327 | + av_freep(&s->temp[i]); | |
| 328 | + s->temp16[i] = NULL; | |
| 329 | + } | |
| 330 | + | |
| 327 | 331 | av_freep(&s->bitstream_buffer); |
| 328 | 332 | |
| 329 | 333 | for (i = 0; i < 8; i++) |
| @@ -599,8 +603,12 @@ static av_cold int decode_init(AVCodecContext *avctx) · 269 unmodified lines | ||
| 599 | 603 | return AVERROR_INVALIDDATA; |
| 600 | 604 | } |
| 601 | 605 | |
| 602 | − if ((ret = ff_huffyuv_alloc_temp(s->temp, s->temp16, avctx->width)) < 0) | |
| 603 | − return ret; | |
| 606 | + for (int i = 0; i < 3; i++) { | |
| 607 | + s->temp[i] = av_malloc(4 * avctx->width + 16); | |
| 608 | + if (!s->temp[i]) | |
| 609 | + return AVERROR(ENOMEM); | |
| 610 | + s->temp16[i] = (uint16_t*)s->temp[i]; | |
| 611 | + } | |
| 604 | 612 | |
| 605 | 613 | return 0; |
| 606 | 614 | } |
| @@ -430,12 +430,15 @@ static av_cold int encode_init(AVCodecContext *avctx) · 429 unmodified lines | ||
| 430 | 430 | s->stats[i][j]= 0; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | − ret = ff_huffyuv_alloc_temp(s->temp, s->temp16, avctx->width); | |
| 434 | − if (ret < 0) | |
| 435 | − return ret; | |
| 436 | − | |
| 437 | 433 | s->picture_number=0; |
| 438 | 434 | |
| 435 | + for (int i = 0; i < 3; i++) { | |
| 436 | + s->temp[i] = av_malloc(4 * avctx->width + 16); | |
| 437 | + if (!s->temp[i]) | |
| 438 | + return AVERROR(ENOMEM); | |
| 439 | + s->temp16[i] = (uint16_t*)s->temp[i]; | |
| 440 | + } | |
| 441 | + | |
| 439 | 442 | return 0; |
| 440 | 443 | } |
| 441 | 444 | static int encode_422_bitstream(HYuvEncContext *s, int offset, int count) |
| @@ -1035,10 +1038,13 @@ static av_cold int encode_end(AVCodecContext *avctx) · 593 unmodified lines | ||
| 1035 | 1038 | { |
| 1036 | 1039 | HYuvEncContext *s = avctx->priv_data; |
| 1037 | 1040 | |
| 1038 | − ff_huffyuv_common_end(s->temp, s->temp16); | |
| 1039 | − | |
| 1040 | 1041 | av_freep(&avctx->stats_out); |
| 1041 | 1042 | |
| 1043 | + for (int i = 0; i < 3; i++) { | |
| 1044 | + av_freep(&s->temp[i]); | |
| 1045 | + s->temp16[i] = NULL; | |
| 1046 | + } | |
| 1047 | + | |
| 1042 | 1048 | return 0; |
| 1043 | 1049 | } |
| 1044 | 1050 | |