| 140 | } |
| 141 | |
| 142 | static int get_encode_buffer(SnowContext *s, AVFrame *frame) |
| 143 | { |
| 144 | int ret; |
| 145 | |
| 146 | frame->width = s->avctx->width + 2 * EDGE_WIDTH; |
| 147 | frame->height = s->avctx->height + 2 * EDGE_WIDTH; |
| 148 | |
| 149 | ret = ff_encode_alloc_frame(s->avctx, frame); |
| 150 | if (ret < 0) |
| 151 | return ret; |
| 152 | for (int i = 0; frame->data[i]; i++) { |
| 153 | int offset = (EDGE_WIDTH >> (i ? s->chroma_v_shift : 0)) * |
| 154 | frame->linesize[i] + |
| 155 | (EDGE_WIDTH >> (i ? s->chroma_h_shift : 0)); |
| 156 | frame->data[i] += offset; |
| 157 | } |
| 158 | frame->width = s->avctx->width; |
| 159 | frame->height = s->avctx->height; |
| 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | static av_cold int encode_init(AVCodecContext *avctx) |
| 165 | { |
no test coverage detected