| 1563 | } FilterPriv; |
| 1564 | |
| 1565 | static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) |
| 1566 | { |
| 1567 | AVFilterContext *ctx = codec->opaque; |
| 1568 | AVFilterPicRef *ref; |
| 1569 | int perms = AV_PERM_WRITE; |
| 1570 | int w, h, stride[4]; |
| 1571 | unsigned edge; |
| 1572 | |
| 1573 | if(pic->buffer_hints & FF_BUFFER_HINTS_VALID) { |
| 1574 | if(pic->buffer_hints & FF_BUFFER_HINTS_READABLE) perms |= AV_PERM_READ; |
| 1575 | if(pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE) perms |= AV_PERM_PRESERVE; |
| 1576 | if(pic->buffer_hints & FF_BUFFER_HINTS_REUSABLE) perms |= AV_PERM_REUSE2; |
| 1577 | } |
| 1578 | if(pic->reference) perms |= AV_PERM_READ | AV_PERM_PRESERVE; |
| 1579 | |
| 1580 | w = codec->width; |
| 1581 | h = codec->height; |
| 1582 | avcodec_align_dimensions2(codec, &w, &h, stride); |
| 1583 | edge = codec->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width(); |
| 1584 | w += edge << 1; |
| 1585 | h += edge << 1; |
| 1586 | |
| 1587 | if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], perms, w, h))) |
| 1588 | return -1; |
| 1589 | |
| 1590 | ref->w = codec->width; |
| 1591 | ref->h = codec->height; |
| 1592 | for(int i = 0; i < 3; i ++) { |
| 1593 | unsigned hshift = i == 0 ? 0 : av_pix_fmt_descriptors[ref->pic->format].log2_chroma_w; |
| 1594 | unsigned vshift = i == 0 ? 0 : av_pix_fmt_descriptors[ref->pic->format].log2_chroma_h; |
| 1595 | |
| 1596 | if (ref->data[i]) { |
| 1597 | ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift); |
| 1598 | } |
| 1599 | pic->data[i] = ref->data[i]; |
| 1600 | pic->linesize[i] = ref->linesize[i]; |
| 1601 | } |
| 1602 | pic->opaque = ref; |
| 1603 | pic->age = INT_MAX; |
| 1604 | pic->type = FF_BUFFER_TYPE_USER; |
| 1605 | return 0; |
| 1606 | } |
| 1607 | |
| 1608 | static void input_release_buffer(AVCodecContext *codec, AVFrame *pic) |
| 1609 | { |
nothing calls this directly
no test coverage detected