Perform QSV-accelerated H.264 decoding with output frames in the GPU video surfaces, write the decoded frames to an output file.
/*
* Copyright (c) 2015 Anton Khirnov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file Intel QSV-accelerated H.264 decoding API usage example
* @example qsv_decode.c
*
* Perform QSV-accelerated H.264 decoding with output frames in the
* GPU video surfaces, write the decoded frames to an output file.
*/
#include <stdio.h>
{
}
}
fprintf(stderr, "The QSV pixel format not offered in get_format()\n");
}
{
fprintf(stderr, "Error during decoding\n");
}
break;
fprintf(stderr, "Error during decoding\n");
}
/* A real program would do something useful with the decoded frame here.
* We just retrieve the raw data and write it to a file, which is rather
* useless but pedagogic. */
fprintf(stderr, "Error transferring the data to system memory\n");
}
for (j = 0; j < (sw_frame->
height >> (
i > 0)); j++)
}
return 0;
}
int main(
int argc,
char **argv)
{
if (argc < 3) {
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
return 1;
}
/* open the input file */
fprintf(stderr, "Cannot open input file '%s': ", argv[1]);
}
/* find the first H.264 video stream */
else
}
fprintf(stderr, "No H.264 video stream in the input file\n");
}
/* open the hardware device */
fprintf(stderr, "Cannot open the hardware device\n");
}
/* initialize the decoder */
fprintf(stderr, "The QSV decoder is not present in libavcodec\n");
}
}
}
}
fprintf(stderr, "Error opening the decoder: ");
}
/* open the output stream */
fprintf(stderr, "Error opening the output context: ");
}
}
/* actual decoding */
break;
}
/* flush the decoder */
char buf[1024];
fprintf(stderr, "%s\n", buf);
}
}