History

avdevice/xcbgrab: move some initialization code from pixfmt_from_pixmap_format to create_stream

Marton Balint committed 6 years ago

Commit b7e94ad1 parent fee4caf1 file · +13 −11Browse files

Unified · Split

libavdevice/xcbgrab.c+13−11
@@ -487,7 +487,7 @@ static xcb_screen_t *get_screen(const xcb_setup_t *setup, int screen_num) · 486 unmodified lines
487487 }
488488
489489 static int pixfmt_from_pixmap_format(AVFormatContext *s, int depth,
490− int *pix_fmt)
490+ int *pix_fmt, int *bpp)
491491 {
492492 XCBGrabContext *c = s->priv_data;
493493 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
525525 }
526526
527527 if (*pix_fmt) {
528− c->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
528+ *bpp = fmt->bits_per_pixel;
536529 return 0;
537530 }
538531
@@ -592,9 +585,18 @@ static int create_stream(AVFormatContext *s) · 53 unmodified lines
592585 st->codecpar->width = c->width;
593586 st->codecpar->height = c->height;
594587
595− ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format);
596−
588+ ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format, &c->bpp);
597589 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
598600
599601 return ret;
600602 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t