You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

571 lines
23KB

  1. /*
  2. * Copyright (c) 2005 Robert Edele <yartrebo@earthlink.net>
  3. * Copyright (c) 2012 Stefano Sabatini
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file advanced blur-based logo removing filter
  23. *
  24. * This filter loads an image mask file showing where a logo is and
  25. * uses a blur transform to remove the logo.
  26. *
  27. * Based on the libmpcodecs remove-logo filter by Robert Edele.
  28. */
  29. /**
  30. * This code implements a filter to remove annoying TV logos and other annoying
  31. * images placed onto a video stream. It works by filling in the pixels that
  32. * comprise the logo with neighboring pixels. The transform is very loosely
  33. * based on a gaussian blur, but it is different enough to merit its own
  34. * paragraph later on. It is a major improvement on the old delogo filter as it
  35. * both uses a better blurring algorithm and uses a bitmap to use an arbitrary
  36. * and generally much tighter fitting shape than a rectangle.
  37. *
  38. * The logo removal algorithm has two key points. The first is that it
  39. * distinguishes between pixels in the logo and those not in the logo by using
  40. * the passed-in bitmap. Pixels not in the logo are copied over directly without
  41. * being modified and they also serve as source pixels for the logo
  42. * fill-in. Pixels inside the logo have the mask applied.
  43. *
  44. * At init-time the bitmap is reprocessed internally, and the distance to the
  45. * nearest edge of the logo (Manhattan distance), along with a little extra to
  46. * remove rough edges, is stored in each pixel. This is done using an in-place
  47. * erosion algorithm, and incrementing each pixel that survives any given
  48. * erosion. Once every pixel is eroded, the maximum value is recorded, and a
  49. * set of masks from size 0 to this size are generaged. The masks are circular
  50. * binary masks, where each pixel within a radius N (where N is the size of the
  51. * mask) is a 1, and all other pixels are a 0. Although a gaussian mask would be
  52. * more mathematically accurate, a binary mask works better in practice because
  53. * we generally do not use the central pixels in the mask (because they are in
  54. * the logo region), and thus a gaussian mask will cause too little blur and
  55. * thus a very unstable image.
  56. *
  57. * The mask is applied in a special way. Namely, only pixels in the mask that
  58. * line up to pixels outside the logo are used. The dynamic mask size means that
  59. * the mask is just big enough so that the edges touch pixels outside the logo,
  60. * so the blurring is kept to a minimum and at least the first boundary
  61. * condition is met (that the image function itself is continuous), even if the
  62. * second boundary condition (that the derivative of the image function is
  63. * continuous) is not met. A masking algorithm that does preserve the second
  64. * boundary coundition (perhaps something based on a highly-modified bi-cubic
  65. * algorithm) should offer even better results on paper, but the noise in a
  66. * typical TV signal should make anything based on derivatives hopelessly noisy.
  67. */
  68. #include "libavutil/imgutils.h"
  69. #include "avfilter.h"
  70. #include "bbox.h"
  71. #include "lavfutils.h"
  72. #include "lswsutils.h"
  73. typedef struct {
  74. /* Stores our collection of masks. The first is for an array of
  75. the second for the y axis, and the third for the x axis. */
  76. int ***mask;
  77. int max_mask_size;
  78. int mask_w, mask_h;
  79. uint8_t *full_mask_data;
  80. FFBoundingBox full_mask_bbox;
  81. uint8_t *half_mask_data;
  82. FFBoundingBox half_mask_bbox;
  83. } RemovelogoContext;
  84. /**
  85. * Choose a slightly larger mask size to improve performance.
  86. *
  87. * This function maps the absolute minimum mask size needed to the
  88. * mask size we'll actually use. f(x) = x (the smallest that will
  89. * work) will produce the sharpest results, but will be quite
  90. * jittery. f(x) = 1.25x (what I'm using) is a good tradeoff in my
  91. * opinion. This will calculate only at init-time, so you can put a
  92. * long expression here without effecting performance.
  93. */
  94. #define apply_mask_fudge_factor(x) (((x) >> 2) + x)
  95. /**
  96. * Pre-process an image to give distance information.
  97. *
  98. * This function takes a bitmap image and converts it in place into a
  99. * distance image. A distance image is zero for pixels outside of the
  100. * logo and is the Manhattan distance (|dx| + |dy|) from the logo edge
  101. * for pixels inside of the logo. This will overestimate the distance,
  102. * but that is safe, and is far easier to implement than a proper
  103. * pythagorean distance since I'm using a modified erosion algorithm
  104. * to compute the distances.
  105. *
  106. * @param mask image which will be converted from a greyscale image
  107. * into a distance image.
  108. */
  109. static void convert_mask_to_strength_mask(uint8_t *data, int linesize,
  110. int w, int h, int min_val,
  111. int *max_mask_size)
  112. {
  113. int x, y;
  114. /* How many times we've gone through the loop. Used in the
  115. in-place erosion algorithm and to get us max_mask_size later on. */
  116. int current_pass = 0;
  117. /* set all non-zero values to 1 */
  118. for (y = 0; y < h; y++)
  119. for (x = 0; x < w; x++)
  120. data[y*linesize + x] = data[y*linesize + x] > min_val;
  121. /* For each pass, if a pixel is itself the same value as the
  122. current pass, and its four neighbors are too, then it is
  123. incremented. If no pixels are incremented by the end of the
  124. pass, then we go again. Edge pixels are counted as always
  125. excluded (this should be true anyway for any sane mask, but if
  126. it isn't this will ensure that we eventually exit). */
  127. while (1) {
  128. /* If this doesn't get set by the end of this pass, then we're done. */
  129. int has_anything_changed = 0;
  130. uint8_t *current_pixel0 = data, *current_pixel;
  131. current_pass++;
  132. for (y = 1; y < h-1; y++) {
  133. current_pixel = current_pixel0;
  134. for (x = 1; x < w-1; x++) {
  135. /* Apply the in-place erosion transform. It is based
  136. on the following two premises:
  137. 1 - Any pixel that fails 1 erosion will fail all
  138. future erosions.
  139. 2 - Only pixels having survived all erosions up to
  140. the present will be >= to current_pass.
  141. It doesn't matter if it survived the current pass,
  142. failed it, or hasn't been tested yet. By using >=
  143. instead of ==, we allow the algorithm to work in
  144. place. */
  145. if ( *current_pixel >= current_pass &&
  146. *(current_pixel + 1) >= current_pass &&
  147. *(current_pixel - 1) >= current_pass &&
  148. *(current_pixel + w) >= current_pass &&
  149. *(current_pixel - w) >= current_pass) {
  150. /* Increment the value since it still has not been
  151. * eroded, as evidenced by the if statement that
  152. * just evaluated to true. */
  153. (*current_pixel)++;
  154. has_anything_changed = 1;
  155. }
  156. current_pixel++;
  157. }
  158. current_pixel0 += linesize;
  159. }
  160. if (!has_anything_changed)
  161. break;
  162. }
  163. /* Apply the fudge factor, which will increase the size of the
  164. * mask a little to reduce jitter at the cost of more blur. */
  165. for (y = 1; y < h - 1; y++)
  166. for (x = 1; x < w - 1; x++)
  167. data[(y * linesize) + x] = apply_mask_fudge_factor(data[(y * linesize) + x]);
  168. /* As a side-effect, we now know the maximum mask size, which
  169. * we'll use to generate our masks. */
  170. /* Apply the fudge factor to this number too, since we must ensure
  171. * that enough masks are generated. */
  172. *max_mask_size = apply_mask_fudge_factor(current_pass + 1);
  173. }
  174. static int query_formats(AVFilterContext *ctx)
  175. {
  176. enum PixelFormat pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
  177. avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts));
  178. return 0;
  179. }
  180. static int load_mask(uint8_t **mask, int *w, int *h,
  181. const char *filename, void *log_ctx)
  182. {
  183. int ret;
  184. enum PixelFormat pix_fmt;
  185. uint8_t *src_data[4], *gray_data[4];
  186. int src_linesize[4], gray_linesize[4];
  187. /* load image from file */
  188. if ((ret = ff_load_image(src_data, src_linesize, w, h, &pix_fmt, filename, log_ctx)) < 0)
  189. return ret;
  190. /* convert the image to GRAY8 */
  191. if ((ret = ff_scale_image(gray_data, gray_linesize, *w, *h, PIX_FMT_GRAY8,
  192. src_data, src_linesize, *w, *h, pix_fmt,
  193. log_ctx)) < 0)
  194. goto end;
  195. /* copy mask to a newly allocated array */
  196. *mask = av_malloc(*w * *h);
  197. if (!*mask)
  198. ret = AVERROR(ENOMEM);
  199. av_image_copy_plane(*mask, *w, gray_data[0], gray_linesize[0], *w, *h);
  200. end:
  201. av_free(src_data[0]);
  202. av_free(gray_data[0]);
  203. return ret;
  204. }
  205. /**
  206. * Generate a scaled down image with half width, height, and intensity.
  207. *
  208. * This function not only scales down an image, but halves the value
  209. * in each pixel too. The purpose of this is to produce a chroma
  210. * filter image out of a luma filter image. The pixel values store the
  211. * distance to the edge of the logo and halving the dimensions halves
  212. * the distance. This function rounds up, because a downwards rounding
  213. * error could cause the filter to fail, but an upwards rounding error
  214. * will only cause a minor amount of excess blur in the chroma planes.
  215. */
  216. static void generate_half_size_image(const uint8_t *src_data, int src_linesize,
  217. uint8_t *dst_data, int dst_linesize,
  218. int src_w, int src_h,
  219. int *max_mask_size)
  220. {
  221. int x, y;
  222. /* Copy over the image data, using the average of 4 pixels for to
  223. * calculate each downsampled pixel. */
  224. for (y = 0; y < src_h/2; y++) {
  225. for (x = 0; x < src_w/2; x++) {
  226. /* Set the pixel if there exists a non-zero value in the
  227. * source pixels, else clear it. */
  228. dst_data[(y * dst_linesize) + x] =
  229. src_data[((y << 1) * src_linesize) + (x << 1)] ||
  230. src_data[((y << 1) * src_linesize) + (x << 1) + 1] ||
  231. src_data[(((y << 1) + 1) * src_linesize) + (x << 1)] ||
  232. src_data[(((y << 1) + 1) * src_linesize) + (x << 1) + 1];
  233. dst_data[(y * dst_linesize) + x] = FFMIN(1, dst_data[(y * dst_linesize) + x]);
  234. }
  235. }
  236. convert_mask_to_strength_mask(dst_data, dst_linesize,
  237. src_w/2, src_h/2, 0, max_mask_size);
  238. }
  239. static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
  240. {
  241. RemovelogoContext *removelogo = ctx->priv;
  242. int ***mask;
  243. int ret = 0;
  244. int a, b, c, w, h;
  245. int full_max_mask_size, half_max_mask_size;
  246. if (!args) {
  247. av_log(ctx, AV_LOG_ERROR, "An image file must be specified as argument\n");
  248. return AVERROR(EINVAL);
  249. }
  250. /* Load our mask image. */
  251. if ((ret = load_mask(&removelogo->full_mask_data, &w, &h, args, ctx)) < 0)
  252. return ret;
  253. removelogo->mask_w = w;
  254. removelogo->mask_h = h;
  255. convert_mask_to_strength_mask(removelogo->full_mask_data, w, w, h,
  256. 16, &full_max_mask_size);
  257. /* Create the scaled down mask image for the chroma planes. */
  258. if (!(removelogo->half_mask_data = av_mallocz(w/2 * h/2)))
  259. return AVERROR(ENOMEM);
  260. generate_half_size_image(removelogo->full_mask_data, w,
  261. removelogo->half_mask_data, w/2,
  262. w, h, &half_max_mask_size);
  263. removelogo->max_mask_size = FFMAX(full_max_mask_size, half_max_mask_size);
  264. /* Create a circular mask for each size up to max_mask_size. When
  265. the filter is applied, the mask size is determined on a pixel
  266. by pixel basis, with pixels nearer the edge of the logo getting
  267. smaller mask sizes. */
  268. mask = (int ***)av_malloc(sizeof(int **) * (removelogo->max_mask_size + 1));
  269. if (!mask)
  270. return AVERROR(ENOMEM);
  271. for (a = 0; a <= removelogo->max_mask_size; a++) {
  272. mask[a] = (int **)av_malloc(sizeof(int *) * ((a * 2) + 1));
  273. if (!mask[a])
  274. return AVERROR(ENOMEM);
  275. for (b = -a; b <= a; b++) {
  276. mask[a][b + a] = (int *)av_malloc(sizeof(int) * ((a * 2) + 1));
  277. if (!mask[a][b + a])
  278. return AVERROR(ENOMEM);
  279. for (c = -a; c <= a; c++) {
  280. if ((b * b) + (c * c) <= (a * a)) /* Circular 0/1 mask. */
  281. mask[a][b + a][c + a] = 1;
  282. else
  283. mask[a][b + a][c + a] = 0;
  284. }
  285. }
  286. }
  287. removelogo->mask = mask;
  288. /* Calculate our bounding rectangles, which determine in what
  289. * region the logo resides for faster processing. */
  290. ff_calculate_bounding_box(&removelogo->full_mask_bbox, removelogo->full_mask_data, w, w, h, 0);
  291. ff_calculate_bounding_box(&removelogo->half_mask_bbox, removelogo->half_mask_data, w/2, w/2, h/2, 0);
  292. #define SHOW_LOGO_INFO(mask_type) \
  293. av_log(ctx, AV_LOG_INFO, #mask_type " x1:%d x2:%d y1:%d y2:%d max_mask_size:%d\n", \
  294. removelogo->mask_type##_mask_bbox.x1, removelogo->mask_type##_mask_bbox.x2, \
  295. removelogo->mask_type##_mask_bbox.y1, removelogo->mask_type##_mask_bbox.y2, \
  296. mask_type##_max_mask_size);
  297. SHOW_LOGO_INFO(full);
  298. SHOW_LOGO_INFO(half);
  299. return 0;
  300. }
  301. static int config_props_input(AVFilterLink *inlink)
  302. {
  303. AVFilterContext *ctx = inlink->dst;
  304. RemovelogoContext *removelogo = ctx->priv;
  305. if (inlink->w != removelogo->mask_w || inlink->h != removelogo->mask_h) {
  306. av_log(ctx, AV_LOG_INFO,
  307. "Mask image size %dx%d does not match with the input video size %dx%d\n",
  308. removelogo->mask_w, removelogo->mask_h, inlink->w, inlink->h);
  309. return AVERROR(EINVAL);
  310. }
  311. return 0;
  312. }
  313. /**
  314. * Blur image.
  315. *
  316. * It takes a pixel that is inside the mask and blurs it. It does so
  317. * by finding the average of all the pixels within the mask and
  318. * outside of the mask.
  319. *
  320. * @param mask_data the mask plane to use for averaging
  321. * @param image_data the image plane to blur
  322. * @param w width of the image
  323. * @param h height of the image
  324. * @param x x-coordinate of the pixel to blur
  325. * @param y y-coordinate of the pixel to blur
  326. */
  327. static unsigned int blur_pixel(int ***mask,
  328. const uint8_t *mask_data, int mask_linesize,
  329. uint8_t *image_data, int image_linesize,
  330. int w, int h, int x, int y)
  331. {
  332. /* Mask size tells how large a circle to use. The radius is about
  333. * (slightly larger than) mask size. */
  334. int mask_size;
  335. int start_posx, start_posy, end_posx, end_posy;
  336. int i, j;
  337. unsigned int accumulator = 0, divisor = 0;
  338. /* What pixel we are reading out of the circular blur mask. */
  339. const uint8_t *image_read_position;
  340. /* What pixel we are reading out of the filter image. */
  341. const uint8_t *mask_read_position;
  342. /* Prepare our bounding rectangle and clip it if need be. */
  343. mask_size = mask_data[y * mask_linesize + x];
  344. start_posx = FFMAX(0, x - mask_size);
  345. start_posy = FFMAX(0, y - mask_size);
  346. end_posx = FFMIN(w - 1, x + mask_size);
  347. end_posy = FFMIN(h - 1, y + mask_size);
  348. image_read_position = image_data + image_linesize * start_posy + start_posx;
  349. mask_read_position = mask_data + mask_linesize * start_posy + start_posx;
  350. for (j = start_posy; j <= end_posy; j++) {
  351. for (i = start_posx; i <= end_posx; i++) {
  352. /* Check if this pixel is in the mask or not. Only use the
  353. * pixel if it is not. */
  354. if (!(*mask_read_position) && mask[mask_size][i - start_posx][j - start_posy]) {
  355. accumulator += *image_read_position;
  356. divisor++;
  357. }
  358. image_read_position++;
  359. mask_read_position++;
  360. }
  361. image_read_position += (image_linesize - ((end_posx + 1) - start_posx));
  362. mask_read_position += (mask_linesize - ((end_posx + 1) - start_posx));
  363. }
  364. /* If divisor is 0, it means that not a single pixel is outside of
  365. the logo, so we have no data. Else we need to normalise the
  366. data using the divisor. */
  367. return divisor == 0 ? 255:
  368. (accumulator + (divisor / 2)) / divisor; /* divide, taking into account average rounding error */
  369. }
  370. /**
  371. * Blur image plane using a mask.
  372. *
  373. * @param source The image to have it's logo removed.
  374. * @param destination Where the output image will be stored.
  375. * @param source_stride How far apart (in memory) two consecutive lines are.
  376. * @param destination Same as source_stride, but for the destination image.
  377. * @param width Width of the image. This is the same for source and destination.
  378. * @param height Height of the image. This is the same for source and destination.
  379. * @param is_image_direct If the image is direct, then source and destination are
  380. * the same and we can save a lot of time by not copying pixels that
  381. * haven't changed.
  382. * @param filter The image that stores the distance to the edge of the logo for
  383. * each pixel.
  384. * @param logo_start_x smallest x-coordinate that contains at least 1 logo pixel.
  385. * @param logo_start_y smallest y-coordinate that contains at least 1 logo pixel.
  386. * @param logo_end_x largest x-coordinate that contains at least 1 logo pixel.
  387. * @param logo_end_y largest y-coordinate that contains at least 1 logo pixel.
  388. *
  389. * This function processes an entire plane. Pixels outside of the logo are copied
  390. * to the output without change, and pixels inside the logo have the de-blurring
  391. * function applied.
  392. */
  393. static void blur_image(int ***mask,
  394. const uint8_t *src_data, int src_linesize,
  395. uint8_t *dst_data, int dst_linesize,
  396. const uint8_t *mask_data, int mask_linesize,
  397. int w, int h, int direct,
  398. FFBoundingBox *bbox)
  399. {
  400. int x, y;
  401. uint8_t *dst_line;
  402. const uint8_t *src_line;
  403. if (!direct)
  404. av_image_copy_plane(dst_data, dst_linesize, src_data, src_linesize, w, h);
  405. for (y = bbox->y1; y <= bbox->y2; y++) {
  406. src_line = src_data + src_linesize * y;
  407. dst_line = dst_data + dst_linesize * y;
  408. for (x = bbox->x1; x <= bbox->x2; x++) {
  409. if (mask_data[y * mask_linesize + x]) {
  410. /* Only process if we are in the mask. */
  411. dst_line[x] = blur_pixel(mask,
  412. mask_data, mask_linesize,
  413. dst_data, dst_linesize,
  414. w, h, x, y);
  415. } else {
  416. /* Else just copy the data. */
  417. if (!direct)
  418. dst_line[x] = src_line[x];
  419. }
  420. }
  421. }
  422. }
  423. static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
  424. {
  425. AVFilterLink *outlink = inlink->dst->outputs[0];
  426. AVFilterBufferRef *outpicref;
  427. if (inpicref->perms & AV_PERM_PRESERVE) {
  428. outpicref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
  429. outlink->w, outlink->h);
  430. avfilter_copy_buffer_ref_props(outpicref, inpicref);
  431. outpicref->video->w = outlink->w;
  432. outpicref->video->h = outlink->h;
  433. } else
  434. outpicref = inpicref;
  435. outlink->out_buf = outpicref;
  436. avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
  437. }
  438. static void end_frame(AVFilterLink *inlink)
  439. {
  440. RemovelogoContext *removelogo = inlink->dst->priv;
  441. AVFilterLink *outlink = inlink->dst->outputs[0];
  442. AVFilterBufferRef *inpicref = inlink ->cur_buf;
  443. AVFilterBufferRef *outpicref = outlink->out_buf;
  444. int direct = inpicref == outpicref;
  445. blur_image(removelogo->mask,
  446. inpicref ->data[0], inpicref ->linesize[0],
  447. outpicref->data[0], outpicref->linesize[0],
  448. removelogo->full_mask_data, inlink->w,
  449. inlink->w, inlink->h, direct, &removelogo->full_mask_bbox);
  450. blur_image(removelogo->mask,
  451. inpicref ->data[1], inpicref ->linesize[1],
  452. outpicref->data[1], outpicref->linesize[1],
  453. removelogo->half_mask_data, inlink->w/2,
  454. inlink->w/2, inlink->h/2, direct, &removelogo->half_mask_bbox);
  455. blur_image(removelogo->mask,
  456. inpicref ->data[2], inpicref ->linesize[2],
  457. outpicref->data[2], outpicref->linesize[2],
  458. removelogo->half_mask_data, inlink->w/2,
  459. inlink->w/2, inlink->h/2, direct, &removelogo->half_mask_bbox);
  460. avfilter_draw_slice(outlink, 0, inlink->h, 1);
  461. avfilter_end_frame(outlink);
  462. avfilter_unref_buffer(inpicref);
  463. if (!direct)
  464. avfilter_unref_buffer(outpicref);
  465. }
  466. static void uninit(AVFilterContext *ctx)
  467. {
  468. RemovelogoContext *removelogo = ctx->priv;
  469. int a, b;
  470. av_freep(&removelogo->full_mask_data);
  471. av_freep(&removelogo->half_mask_data);
  472. if (removelogo->mask) {
  473. /* Loop through each mask. */
  474. for (a = 0; a <= removelogo->max_mask_size; a++) {
  475. /* Loop through each scanline in a mask. */
  476. for (b = -a; b <= a; b++) {
  477. av_free(removelogo->mask[a][b + a]); /* Free a scanline. */
  478. }
  479. av_free(removelogo->mask[a]);
  480. }
  481. /* Free the array of pointers pointing to the masks. */
  482. av_freep(&removelogo->mask);
  483. }
  484. }
  485. static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { }
  486. AVFilter avfilter_vf_removelogo = {
  487. .name = "removelogo",
  488. .description = NULL_IF_CONFIG_SMALL("Remove a TV logo based on a mask image."),
  489. .priv_size = sizeof(RemovelogoContext),
  490. .init = init,
  491. .uninit = uninit,
  492. .query_formats = query_formats,
  493. .inputs = (const AVFilterPad[]) {
  494. { .name = "default",
  495. .type = AVMEDIA_TYPE_VIDEO,
  496. .get_video_buffer = avfilter_null_get_video_buffer,
  497. .config_props = config_props_input,
  498. .draw_slice = null_draw_slice,
  499. .start_frame = start_frame,
  500. .end_frame = end_frame,
  501. .min_perms = AV_PERM_WRITE | AV_PERM_READ,
  502. .rej_perms = AV_PERM_PRESERVE },
  503. { .name = NULL }
  504. },
  505. .outputs = (const AVFilterPad[]) {
  506. { .name = "default",
  507. .type = AVMEDIA_TYPE_VIDEO, },
  508. { .name = NULL }
  509. },
  510. };