MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / get_image_format

Function get_image_format

libavdevice/android_camera.c:338–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336}
337
338static int get_image_format(AVFormatContext *avctx, AImage *image)
339{
340 AndroidCameraCtx *ctx = avctx->priv_data;
341 int32_t image_pixelstrides[2];
342 uint8_t *image_plane_data[2];
343 int plane_data_length[2];
344
345 for (int i = 0; i < 2; i++) {
346 AImage_getPlanePixelStride(image, i + 1, &image_pixelstrides[i]);
347 AImage_getPlaneData(image, i + 1, &image_plane_data[i], &plane_data_length[i]);
348 }
349
350 if (image_pixelstrides[0] != image_pixelstrides[1]) {
351 av_log(avctx, AV_LOG_ERROR,
352 "Pixel strides of U and V plane should have been the same.\n");
353 return AVERROR_EXTERNAL;
354 }
355
356 switch (image_pixelstrides[0]) {
357 case 1:
358 ctx->image_format = AV_PIX_FMT_YUV420P;
359 break;
360 case 2:
361 if (image_plane_data[0] < image_plane_data[1]) {
362 ctx->image_format = AV_PIX_FMT_NV12;
363 } else {
364 ctx->image_format = AV_PIX_FMT_NV21;
365 }
366 break;
367 default:
368 av_log(avctx, AV_LOG_ERROR,
369 "Unknown pixel stride %d of U and V plane, cannot determine camera image format.\n",
370 image_pixelstrides[0]);
371 return AVERROR(ENOSYS);
372 }
373
374 return 0;
375}
376
377static void image_available(void *context, AImageReader *reader)
378{

Callers 1

image_availableFunction · 0.85

Calls 1

av_logFunction · 0.85

Tested by

no test coverage detected