Unified · Split
| @@ -487,7 +487,7 @@ static xcb_screen_t *get_screen(const xcb_setup_t *setup, int screen_num) · 486 unmodified lines | |||
| 487 | } | 487 | } |
| 488 | 488 | ||
| 489 | static int pixfmt_from_pixmap_format(AVFormatContext *s, int depth, | 489 | static int pixfmt_from_pixmap_format(AVFormatContext *s, int depth, |
| 490 | int *pix_fmt) | 490 | int *pix_fmt, int *bpp) |
| 491 | { | 491 | { |
| 492 | XCBGrabContext *c = s->priv_data; | 492 | XCBGrabContext *c = s->priv_data; |
| 493 | const xcb_setup_t *setup = xcb_get_setup(c->conn); | 493 | const xcb_setup_t *setup = xcb_get_setup(c->conn); |
| @@ -525,14 +525,7 @@ static int pixfmt_from_pixmap_format(AVFormatContext *s, int depth, · 31 unmodified lines | |||
| 525 | } | 525 | } |
| 526 | 526 | ||
| 527 | if (*pix_fmt) { | 527 | if (*pix_fmt) { |
| 528 | c->bpp = fmt->bits_per_pixel; | 528 | *bpp = fmt->bits_per_pixel; |
| 529 | c->frame_size = c->width * c->height * fmt->bits_per_pixel / 8; | ||
| 530 | #if CONFIG_LIBXCB_SHM | ||
| 531 | c->shm_pool = av_buffer_pool_init2(c->frame_size + AV_INPUT_BUFFER_PADDING_SIZE, | ||
| 532 | c->conn, allocate_shm_buffer, NULL); | ||
| 533 | if (!c->shm_pool) | ||
| 534 | return AVERROR(ENOMEM); | ||
| 535 | #endif | ||
| 536 | return 0; | 529 | return 0; |
| 537 | } | 530 | } |
| 538 | 531 | ||
| @@ -592,9 +585,18 @@ static int create_stream(AVFormatContext *s) · 53 unmodified lines | |||
| 592 | st->codecpar->width = c->width; | 585 | st->codecpar->width = c->width; |
| 593 | st->codecpar->height = c->height; | 586 | st->codecpar->height = c->height; |
| 594 | 587 | ||
| 595 | ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format); | 588 | ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format, &c->bpp); |
| 596 | |||
| 597 | free(geo); | 589 | free(geo); |
| 590 | if (ret < 0) | ||
| 591 | return ret; | ||
| 592 | |||
| 593 | c->frame_size = c->width * c->height * c->bpp / 8; | ||
| 594 | #if CONFIG_LIBXCB_SHM | ||
| 595 | c->shm_pool = av_buffer_pool_init2(c->frame_size + AV_INPUT_BUFFER_PADDING_SIZE, | ||
| 596 | c->conn, allocate_shm_buffer, NULL); | ||
| 597 | if (!c->shm_pool) | ||
| 598 | return AVERROR(ENOMEM); | ||
| 599 | #endif | ||
| 598 | 600 | ||
| 599 | return ret; | 601 | return ret; |
| 600 | } | 602 | } |