
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (61)
-
L’agrémenter visuellement
10 avril 2011MediaSPIP est basé sur un système de thèmes et de squelettes. Les squelettes définissent le placement des informations dans la page, définissant un usage spécifique de la plateforme, et les thèmes l’habillage graphique général.
Chacun peut proposer un nouveau thème graphique ou un squelette et le mettre à disposition de la communauté. -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Personnaliser les catégories
21 juin 2013, parFormulaire de création d’une catégorie
Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire.
Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)
Sur d’autres sites (12056)
-
AV_PIX_FMT_YUVJ422P to jpeg conversion
4 mars 2019, par user3743908i am able to convert image from AV_PIX_FMT_YUVJ422P to jpeg format (below Code) but the resultant image having green shade on complete bottom half plz suggest where i am doing wrong.
Following step i have taken-
Initially i have AV_PIX_FMT_UYVY422 image from camera, i have convert it in AV_PIX_FMT_YUVJ422P format and able to see this image on http://rawpixels.net/ the parameters shown by website is size 2448X2050, Bpp1= 8,Bpp2 = 8 and Bpp3 = 8,alignment 1, SubSampling H =2, and SubSampling V = 1, format : YUV422P
so input image is Correct AV_PIX_FMT_YUVJ422P format. & also able to see on "YUV image viewer Software" using YUV422 format. -
Now i am trying to convert it in jpeg format using below Code and attached is the resultant Image having green shade on complete bottom half.
AVFormatContext* pFormatCtx;
AVOutputFormat* fmt;
AVStream* video_st;
AVCodecContext* pCodecCtx;
AVCodec* pCodec;
uint8_t* picture_buf;
AVFrame* picture;
AVPacket pkt;
int y_size;
int size;
int got_picture=0;
int ret=0;
int main( int argc, char* argv[] )
{
FILE *in_file = NULL;
unsigned int in_width = 2448;
unsigned int in_height = 2050;
const char* out_file = "encoded_pic.jpg";
in_file = fopen("c:\\test_Planar.yuv","rb");
if(in_file == NULL) { printf("\n\tFile Opening error...!!"); exit(1); }
else printf("\n\tYUV File Open Sucessfully...!!\n\n");
av_register_all(); // Loads the whole database of available codecs and formats.
pFormatCtx = avformat_alloc_context();
fmt = NULL;
fmt = av_guess_format("mjpeg",NULL,NULL);
pFormatCtx->oformat = fmt;
//------Output URL-------------------------
if (avio_open(&pFormatCtx->pb,out_file, AVIO_FLAG_READ_WRITE) < 0)
{
printf("Couldn't open output file.");
return -1;
}
video_st = avformat_new_stream(pFormatCtx, 0);
if (video_st==NULL) return -1;
pCodecCtx = video_st->codec;
pCodecCtx->codec_id = fmt->video_codec;
pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
pCodecCtx->pix_fmt = AV_PIX_FMT_YUVJ422P;
//--------------------------MY SOURCE PIXEL FORMAT--------------
pCodecCtx->width = in_width;
pCodecCtx->height = in_height;
pCodecCtx->time_base.num = 1;
pCodecCtx->time_base.den = 1;//25;
//Output some information
av_dump_format(pFormatCtx, 0, out_file, 1);
// Determine if desired video encoder is installed
pCodec = avcodec_find_encoder(pCodecCtx->codec_id);
if (!pCodec)
{
printf("Codec not found.");
return -1;
}
printf("\nCodec Identified done\n");
if (avcodec_open2(pCodecCtx, pCodec,NULL) < 0){
printf("Could not open codec.\n");
return -1;
}
picture = av_frame_alloc();
size = avpicture_get_size(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
picture_buf = (uint8_t *)av_malloc(size);
if (!picture_buf) return -1;
avpicture_fill((AVPicture *)picture, picture_buf, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
printf("\t\nWrite Header..");
avformat_write_header(pFormatCtx,NULL);
y_size = pCodecCtx->width * pCodecCtx->height;
av_new_packet(&pkt,y_size*3);
//Read YUV
if (fread(picture_buf, 1, y_size*3/2, in_file) <=0)
{
printf("Could not read input file.");
return -1;
}
//--------------------------------------------input image format UYVY
picture->data[0] = picture_buf; // Y
picture->data[1] = picture_buf+ y_size; // U
picture->data[2] = picture_buf+ y_size*5/4; // V
//-----------------------------------------------
printf("\t\n Encode the image..\n");
ret = avcodec_encode_video2(pCodecCtx, &pkt,picture, &got_picture);
if(ret < 0)
{
printf("Encode Error.\n");
return -1;
}
if (got_picture==1)
{
pkt.stream_index = video_st->index;
ret = av_write_frame(pFormatCtx, &pkt);
}
av_free_packet(&pkt);
//Write Trailer
av_write_trailer(pFormatCtx);
printf("Encode Successful.\n");
if (video_st)
{
avcodec_close(video_st->codec);
av_free(picture);
av_free(picture_buf);
}
avio_close(pFormatCtx->pb);
avformat_free_context(pFormatCtx);
fclose(in_file);
printf("\n\tYUV File Close Sucessfully...!!");
}
Resultant output jpeg encoded image from yuvj422p image having green shade
-
-
Packet (AV_PIX_FMT_UYVY422) to Planar (AV_PIX_FMT_YUVJ422P) format conversion
25 août 2017, par user3743908My image format is "YUV422_8_UYVY" which is packed AV_PIX_FMT_UYVY422 format, i am trying to convert it in Planar "AV_PIX_FMT_YUVJ422P", but not able to succeed yet, below is the code on which i am working.
error message : [swscaler @ 004b3fa0] deprecetd pixel format used, make sure you did set range correctly
resultant image (file ) having 0 k size
what would be the last argument of av_image_alloc() for conversion like 16,32 etc
my aim to convert packet yuv image in planar yuv format
static AVCodecContext *pCodecCtx;
static AVFormatContext *pFormatCtx;
static AVCodec *pCodec;
static AVOutputFormat* fmt;
static AVFrame *RawPic;
static AVFrame *ScalePic;
static AVPacket pkt;
static AVStream* video_st;
static FILE *file;
static struct SwsContext *sws_ctx;
enum AVPixelFormat src_pix_fmt = AV_PIX_FMT_UYVY422;
enum AVPixelFormat dst_pix_fmt = AV_PIX_FMT_YUVJ422P;
int main( ) {
FILE *in_file = NULL; //packed Source
FILE *out_file = NULL; //planar output
int in_width = 2448; //YUV's width
int in_height = 2050; //YUV's heigh
int out_width = 2448; //YUV's width
int out_height = 2050; //YUV's heigh
unsigned long int ret;
in_file = fopen("c:\\yuv422_8_uyvy.yuv","rb"); //Source Input File
if(in_file == NULL) { printf("\n\tinput File Opening error...!!"); exit(1); }
out_file = fopen("d:\\test_Planar.yuv", "wb"); //Source Input File
if(out_file == NULL) { printf("\n\toutput File Opening error...!!"); exit(1); }
else { printf("\n\tOutput File Created...!!"); }
//------Loads the whole database of available codecs and formats------
av_register_all();
printf("\t\n\tCodac database Loaded...\n");
//------Contex Variable assignment--------------------------------
pFormatCtx = avformat_alloc_context();
fmt = NULL;
fmt = av_guess_format("mjpeg",NULL,NULL);
pFormatCtx->oformat = fmt;
video_st = avformat_new_stream(pFormatCtx, 0); if (video_st==NULL) return -1;
pCodecCtx = video_st->codec;
pCodecCtx->codec_id = fmt->video_codec;
pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
pCodecCtx->pix_fmt = src_pix_fmt;
printf("\t\n\tContex Variable assigned...\n");
//------Allocate Source Image Buffer--------------------------------
AVFrame *RawPic = av_frame_alloc();
if(!RawPic) { printf("\nCould not allocate Raw Image frame\n"); exit(1);}
RawPic->format = pCodecCtx->pix_fmt;
RawPic->width = in_width;
RawPic->height = in_height;
ret = av_image_alloc(RawPic->data,RawPic->linesize,in_width,in_height,src_pix_fmt, 16);
if(ret < 0) { printf("\nCould not allocate raw picture buffer\n"); exit(1);}
printf("\n\tAllocate Source Image Buffer");
//------Allocate Desitnation Image Buffer-------------------
AVFrame *ScalePic = av_frame_alloc();
if(!ScalePic) { printf("\nCould not allocate Scale Image frame\n"); exit(1);}
ScalePic->format = pCodecCtx->pix_fmt;
ScalePic->width = out_width;
ScalePic->height = out_height;
ret = av_image_alloc(ScalePic->data,ScalePic->linesize,out_width,out_height,dst_pix_fmt, 32);
if(ret < 0) { printf("\nCould not allocate Scale picture buffer\n"); exit(1);}
dst_bufsize = ret;
printf("\n\tAllocate Destination Image Buffer");
//------Create scaling context------------------------------sws_getContex
printf("\t\n\tCreating Scaling context..[sws_getContext]\n");
sws_ctx = sws_getContext( in_width, in_height, src_pix_fmt,
out_width, out_height, dst_pix_fmt,
SWS_BICUBIC, NULL, NULL, NULL);
if(!sws_ctx) { printf("\nContext Error..\n"); }
printf("\t\n\tScaling context...Created\n");
//------Create scaling context---OR CONVERTED TO DESTINATION FORMAT--
sws_scale(sws_ctx, RawPic->data, RawPic->linesize, 0, in_height, ScalePic->data, ScalePic->linesize);
printf("\t\n\tCreating Scaling context...sws_scale...done\n");
int num_bytes = avpicture_get_size(src_pix_fmt,in_width,in_height);
uint8_t* ScalePic_Buffer = (uint8_t *)av_malloc(num_bytes*sizeof(int8_t));
avpicture_fill((AVPicture*)ScalePic,ScalePic_Buffer,AV_PIX_FMT_YUVJ422P,out_width,out_height);
//-----Write Scale Image to outputfile----------------------------
fwrite(ScalePic->data,1,dst_bufsize,out_file);
//---Release all memory and close file----------------------------------
fclose(in_file);
fclose(out_file);
avcodec_close(pCodecCtx);
av_free(pCodecCtx);
av_freep(&RawPic->data[0]);
av_frame_free(&RawPic);
av_freep(&ScalePic->data[0]);
av_frame_free(&ScalePic);
av_frame_free(&RawPic);
printf("\n\n");
system("PAUSE");
exit(1);
} -
swscale/aarch64/output.S : refactor ff_yuv2plane1_8_neon
31 janvier, par Krzysztof Pyrkoszswscale/aarch64/output.S : refactor ff_yuv2plane1_8_neon
The benchmarks (before vs after) were gathered using
./tests/checkasm/checkasm —test=sw_scale —bench —runs=6 | grep yuv2yuv1A78 before :
yuv2yuv1_0_512_accurate_c : 2039.5 ( 1.00x)
yuv2yuv1_0_512_accurate_neon : 385.5 ( 5.29x)
yuv2yuv1_0_512_approximate_c : 2110.5 ( 1.00x)
yuv2yuv1_0_512_approximate_neon : 385.5 ( 5.47x)
yuv2yuv1_3_512_accurate_c : 2061.2 ( 1.00x)
yuv2yuv1_3_512_accurate_neon : 381.2 ( 5.41x)
yuv2yuv1_3_512_approximate_c : 2099.2 ( 1.00x)
yuv2yuv1_3_512_approximate_neon : 381.2 ( 5.51x)
yuv2yuv1_8_512_accurate_c : 2054.2 ( 1.00x)
yuv2yuv1_8_512_accurate_neon : 385.5 ( 5.33x)
yuv2yuv1_8_512_approximate_c : 2112.2 ( 1.00x)
yuv2yuv1_8_512_approximate_neon : 385.5 ( 5.48x)
yuv2yuv1_11_512_accurate_c : 2036.0 ( 1.00x)
yuv2yuv1_11_512_accurate_neon : 381.2 ( 5.34x)
yuv2yuv1_11_512_approximate_c : 2115.0 ( 1.00x)
yuv2yuv1_11_512_approximate_neon : 381.2 ( 5.55x)
yuv2yuv1_16_512_accurate_c : 2066.5 ( 1.00x)
yuv2yuv1_16_512_accurate_neon : 385.5 ( 5.36x)
yuv2yuv1_16_512_approximate_c : 2100.8 ( 1.00x)
yuv2yuv1_16_512_approximate_neon : 385.5 ( 5.45x)
yuv2yuv1_19_512_accurate_c : 2059.8 ( 1.00x)
yuv2yuv1_19_512_accurate_neon : 381.2 ( 5.40x)
yuv2yuv1_19_512_approximate_c : 2102.8 ( 1.00x)
yuv2yuv1_19_512_approximate_neon : 381.2 ( 5.52x)After :
yuv2yuv1_0_512_accurate_c : 2206.0 ( 1.00x)
yuv2yuv1_0_512_accurate_neon : 139.2 (15.84x)
yuv2yuv1_0_512_approximate_c : 2050.0 ( 1.00x)
yuv2yuv1_0_512_approximate_neon : 139.2 (14.72x)
yuv2yuv1_3_512_accurate_c : 2205.2 ( 1.00x)
yuv2yuv1_3_512_accurate_neon : 138.0 (15.98x)
yuv2yuv1_3_512_approximate_c : 2052.5 ( 1.00x)
yuv2yuv1_3_512_approximate_neon : 138.0 (14.87x)
yuv2yuv1_8_512_accurate_c : 2171.0 ( 1.00x)
yuv2yuv1_8_512_accurate_neon : 139.2 (15.59x)
yuv2yuv1_8_512_approximate_c : 2064.2 ( 1.00x)
yuv2yuv1_8_512_approximate_neon : 139.2 (14.82x)
yuv2yuv1_11_512_accurate_c : 2164.8 ( 1.00x)
yuv2yuv1_11_512_accurate_neon : 138.0 (15.69x)
yuv2yuv1_11_512_approximate_c : 2048.8 ( 1.00x)
yuv2yuv1_11_512_approximate_neon : 138.0 (14.85x)
yuv2yuv1_16_512_accurate_c : 2154.5 ( 1.00x)
yuv2yuv1_16_512_accurate_neon : 139.2 (15.47x)
yuv2yuv1_16_512_approximate_c : 2047.2 ( 1.00x)
yuv2yuv1_16_512_approximate_neon : 139.2 (14.70x)
yuv2yuv1_19_512_accurate_c : 2144.5 ( 1.00x)
yuv2yuv1_19_512_accurate_neon : 138.0 (15.54x)
yuv2yuv1_19_512_approximate_c : 2046.0 ( 1.00x)
yuv2yuv1_19_512_approximate_neon : 138.0 (14.83x)A72 before :
yuv2yuv1_0_512_accurate_c : 3779.8 ( 1.00x)
yuv2yuv1_0_512_accurate_neon : 527.8 ( 7.16x)
yuv2yuv1_0_512_approximate_c : 4128.2 ( 1.00x)
yuv2yuv1_0_512_approximate_neon : 528.2 ( 7.81x)
yuv2yuv1_3_512_accurate_c : 3836.2 ( 1.00x)
yuv2yuv1_3_512_accurate_neon : 527.0 ( 7.28x)
yuv2yuv1_3_512_approximate_c : 3991.0 ( 1.00x)
yuv2yuv1_3_512_approximate_neon : 526.8 ( 7.58x)
yuv2yuv1_8_512_accurate_c : 3732.8 ( 1.00x)
yuv2yuv1_8_512_accurate_neon : 525.5 ( 7.10x)
yuv2yuv1_8_512_approximate_c : 4060.0 ( 1.00x)
yuv2yuv1_8_512_approximate_neon : 527.0 ( 7.70x)
yuv2yuv1_11_512_accurate_c : 3836.2 ( 1.00x)
yuv2yuv1_11_512_accurate_neon : 530.0 ( 7.24x)
yuv2yuv1_11_512_approximate_c : 4014.0 ( 1.00x)
yuv2yuv1_11_512_approximate_neon : 530.0 ( 7.57x)
yuv2yuv1_16_512_accurate_c : 3726.2 ( 1.00x)
yuv2yuv1_16_512_accurate_neon : 525.5 ( 7.09x)
yuv2yuv1_16_512_approximate_c : 4114.2 ( 1.00x)
yuv2yuv1_16_512_approximate_neon : 526.2 ( 7.82x)
yuv2yuv1_19_512_accurate_c : 3812.2 ( 1.00x)
yuv2yuv1_19_512_accurate_neon : 530.0 ( 7.19x)
yuv2yuv1_19_512_approximate_c : 4012.2 ( 1.00x)
yuv2yuv1_19_512_approximate_neon : 530.0 ( 7.57x)After :
yuv2yuv1_0_512_accurate_c : 3716.8 ( 1.00x)
yuv2yuv1_0_512_accurate_neon : 215.1 (17.28x)
yuv2yuv1_0_512_approximate_c : 3877.8 ( 1.00x)
yuv2yuv1_0_512_approximate_neon : 222.8 (17.40x)
yuv2yuv1_3_512_accurate_c : 3717.1 ( 1.00x)
yuv2yuv1_3_512_accurate_neon : 217.8 (17.06x)
yuv2yuv1_3_512_approximate_c : 3801.6 ( 1.00x)
yuv2yuv1_3_512_approximate_neon : 220.3 (17.25x)
yuv2yuv1_8_512_accurate_c : 3716.6 ( 1.00x)
yuv2yuv1_8_512_accurate_neon : 213.8 (17.38x)
yuv2yuv1_8_512_approximate_c : 3831.8 ( 1.00x)
yuv2yuv1_8_512_approximate_neon : 218.1 (17.57x)
yuv2yuv1_11_512_accurate_c : 3717.1 ( 1.00x)
yuv2yuv1_11_512_accurate_neon : 219.1 (16.97x)
yuv2yuv1_11_512_approximate_c : 3801.6 ( 1.00x)
yuv2yuv1_11_512_approximate_neon : 216.1 (17.59x)
yuv2yuv1_16_512_accurate_c : 3716.6 ( 1.00x)
yuv2yuv1_16_512_accurate_neon : 213.6 (17.40x)
yuv2yuv1_16_512_approximate_c : 3831.6 ( 1.00x)
yuv2yuv1_16_512_approximate_neon : 215.1 (17.82x)
yuv2yuv1_19_512_accurate_c : 3717.1 ( 1.00x)
yuv2yuv1_19_512_accurate_neon : 223.8 (16.61x)
yuv2yuv1_19_512_approximate_c : 3801.6 ( 1.00x)
yuv2yuv1_19_512_approximate_neon : 219.1 (17.35x)x13s before :
yuv2yuv1_0_512_accurate_c : 1435.1 ( 1.00x)
yuv2yuv1_0_512_accurate_neon : 221.1 ( 6.49x)
yuv2yuv1_0_512_approximate_c : 1405.4 ( 1.00x)
yuv2yuv1_0_512_approximate_neon : 219.1 ( 6.41x)
yuv2yuv1_3_512_accurate_c : 1418.6 ( 1.00x)
yuv2yuv1_3_512_accurate_neon : 215.9 ( 6.57x)
yuv2yuv1_3_512_approximate_c : 1405.9 ( 1.00x)
yuv2yuv1_3_512_approximate_neon : 224.1 ( 6.27x)
yuv2yuv1_8_512_accurate_c : 1433.9 ( 1.00x)
yuv2yuv1_8_512_accurate_neon : 218.6 ( 6.56x)
yuv2yuv1_8_512_approximate_c : 1412.9 ( 1.00x)
yuv2yuv1_8_512_approximate_neon : 218.9 ( 6.46x)
yuv2yuv1_11_512_accurate_c : 1449.1 ( 1.00x)
yuv2yuv1_11_512_accurate_neon : 217.6 ( 6.66x)
yuv2yuv1_11_512_approximate_c : 1410.9 ( 1.00x)
yuv2yuv1_11_512_approximate_neon : 221.1 ( 6.38x)
yuv2yuv1_16_512_accurate_c : 1402.1 ( 1.00x)
yuv2yuv1_16_512_accurate_neon : 214.6 ( 6.53x)
yuv2yuv1_16_512_approximate_c : 1422.4 ( 1.00x)
yuv2yuv1_16_512_approximate_neon : 222.9 ( 6.38x)
yuv2yuv1_19_512_accurate_c : 1421.6 ( 1.00x)
yuv2yuv1_19_512_accurate_neon : 217.4 ( 6.54x)
yuv2yuv1_19_512_approximate_c : 1421.6 ( 1.00x)
yuv2yuv1_19_512_approximate_neon : 221.4 ( 6.42x)After :
yuv2yuv1_0_512_accurate_c : 1413.6 ( 1.00x)
yuv2yuv1_0_512_accurate_neon : 80.6 (17.53x)
yuv2yuv1_0_512_approximate_c : 1455.6 ( 1.00x)
yuv2yuv1_0_512_approximate_neon : 80.6 (18.05x)
yuv2yuv1_3_512_accurate_c : 1429.1 ( 1.00x)
yuv2yuv1_3_512_accurate_neon : 77.4 (18.47x)
yuv2yuv1_3_512_approximate_c : 1462.6 ( 1.00x)
yuv2yuv1_3_512_approximate_neon : 80.6 (18.14x)
yuv2yuv1_8_512_accurate_c : 1425.4 ( 1.00x)
yuv2yuv1_8_512_accurate_neon : 77.9 (18.30x)
yuv2yuv1_8_512_approximate_c : 1436.6 ( 1.00x)
yuv2yuv1_8_512_approximate_neon : 80.9 (17.76x)
yuv2yuv1_11_512_accurate_c : 1429.4 ( 1.00x)
yuv2yuv1_11_512_accurate_neon : 76.1 (18.78x)
yuv2yuv1_11_512_approximate_c : 1447.1 ( 1.00x)
yuv2yuv1_11_512_approximate_neon : 78.4 (18.46x)
yuv2yuv1_16_512_accurate_c : 1439.9 ( 1.00x)
yuv2yuv1_16_512_accurate_neon : 77.6 (18.55x)
yuv2yuv1_16_512_approximate_c : 1422.1 ( 1.00x)
yuv2yuv1_16_512_approximate_neon : 78.1 (18.20x)
yuv2yuv1_19_512_accurate_c : 1447.1 ( 1.00x)
yuv2yuv1_19_512_accurate_neon : 78.1 (18.52x)
yuv2yuv1_19_512_approximate_c : 1474.4 ( 1.00x)
yuv2yuv1_19_512_approximate_neon : 78.1 (18.87x)Signed-off-by : Martin Storsjö <martin@martin.st>