
Recherche avancée
Autres articles (38)
-
MediaSPIP Core : La Configuration
9 novembre 2010, parMediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...) -
(Dés)Activation de fonctionnalités (plugins)
18 février 2011, parPour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...) -
Soumettre bugs et patchs
10 avril 2011Un logiciel n’est malheureusement jamais parfait...
Si vous pensez avoir mis la main sur un bug, reportez le dans notre système de tickets en prenant bien soin de nous remonter certaines informations pertinentes : le type de navigateur et sa version exacte avec lequel vous avez l’anomalie ; une explication la plus précise possible du problème rencontré ; si possibles les étapes pour reproduire le problème ; un lien vers le site / la page en question ;
Si vous pensez avoir résolu vous même le bug (...)
Sur d’autres sites (5752)
-
How to encode Planar 4:2:0 (fourcc P010)
20 juillet 2021, par DennisFleurbaaijI'm trying to recode fourcc V210 (which is a packed YUV4:2:2 format) into a P010 (planar YUV4:2:0). I think I've implemented it according to spec, but the renderer is giving a wrong image so something is off. Decoding the V210 has a decent example in ffmpeg (defines are modified from their solution) but I can't find a P010 encoder to look at what I'm doing wrong.


(Yes, I've tried ffmpeg and that works but it's too slow for this, it takes 30ms per frame on an Intel Gen11 i7)


Clarification (after @Frank's question) : The frames being processed are 4k (3840px wide) and hence there is no code for doing the 128b alignment.


This is running on intel so little endian conversions applied.


Try1 - all green image :


The following code


#define V210_READ_PACK_BLOCK(a, b, c) \
 do { \
 val = *src++; \
 a = val & 0x3FF; \
 b = (val >> 10) & 0x3FF; \
 c = (val >> 20) & 0x3FF; \
 } while (0)

#define PIXELS_PER_PACK 6
#define BYTES_PER_PACK (4*4)

void MyClass::FormatVideoFrame(
 BYTE* inFrame,
 BYTE* outBuffer)
{
 const uint32_t pixels = m_height * m_width;

 const uint32_t* src = (const uint32_t *)inFrame);

 uint16_t* dstY = (uint16_t *)outBuffer;

 uint16_t* dstUVStart = (uint16_t*)(outBuffer + ((ptrdiff_t)pixels * sizeof(uint16_t)));
 uint16_t* dstUV = dstUVStart;

 const uint32_t packsPerLine = m_width / PIXELS_PER_PACK;

 for (uint32_t line = 0; line < m_height; line++)
 {
 for (uint32_t pack = 0; pack < packsPerLine; pack++)
 {
 uint32_t val;
 uint16_t u, y1, y2, v;

 if (pack % 2 == 0)
 {
 V210_READ_PACK_BLOCK(u, y1, v);
 *dstUV++ = u;
 *dstY++ = y1;
 *dstUV++ = v;

 V210_READ_PACK_BLOCK(y1, u, y2);
 *dstY++ = y1;
 *dstUV++ = u;
 *dstY++ = y2;

 V210_READ_PACK_BLOCK(v, y1, u);
 *dstUV++ = v;
 *dstY++ = y1;
 *dstUV++ = u;

 V210_READ_PACK_BLOCK(y1, v, y2);
 *dstY++ = y1;
 *dstUV++ = v;
 *dstY++ = y2;
 }
 else
 {
 V210_READ_PACK_BLOCK(u, y1, v);
 *dstY++ = y1;

 V210_READ_PACK_BLOCK(y1, u, y2);
 *dstY++ = y1;
 *dstY++ = y2;

 V210_READ_PACK_BLOCK(v, y1, u);
 *dstY++ = y1;

 V210_READ_PACK_BLOCK(y1, v, y2);
 *dstY++ = y1;
 *dstY++ = y2;
 }
 }
 }

#ifdef _DEBUG

 // Fully written Y space
 assert(dstY == dstUVStart);

 // Fully written UV space
 const BYTE* expectedVurrentUVPtr = outBuffer + (ptrdiff_t)GetOutFrameSize();
 assert(expectedVurrentUVPtr == (BYTE *)dstUV);

#endif
}

// This is called to determine outBuffer size
LONG MyClass::GetOutFrameSize() const
{
 const LONG pixels = m_height * m_width;

 return
 (pixels * sizeof(uint16_t)) + // Every pixel 1 y
 (pixels / 2 / 2 * (2 * sizeof(uint16_t))); // Every 2 pixels and every odd row 2 16-bit numbers
}



Leads to all green image. This turned out to be a missing bit shift to place the 10 bits in the upper bits of the 16-bit value as per the P010 spec.


Try 2 - Y works, UV doubled ?


Updated the code to properly (or so I think) shifts the YUV values to the correct position in their 16-bit space.


#define V210_READ_PACK_BLOCK(a, b, c) \
 do { \
 val = *src++; \
 a = val & 0x3FF; \
 b = (val >> 10) & 0x3FF; \
 c = (val >> 20) & 0x3FF; \
 } while (0)


#define P010_WRITE_VALUE(d, v) (*d++ = (v << 6))

#define PIXELS_PER_PACK 6
#define BYTES_PER_PACK (4 * sizeof(uint32_t))

// Snipped constructor here which guarantees that we're processing
// something which does not violate alignment.

void MyClass::FormatVideoFrame(
 const BYTE* inBuffer,
 BYTE* outBuffer)
{ 
 const uint32_t pixels = m_height * m_width;
 const uint32_t aligned_width = ((m_width + 47) / 48) * 48;
 const uint32_t stride = aligned_width * 8 / 3;

 uint16_t* dstY = (uint16_t *)outBuffer;

 uint16_t* dstUVStart = (uint16_t*)(outBuffer + ((ptrdiff_t)pixels * sizeof(uint16_t)));
 uint16_t* dstUV = dstUVStart;

 const uint32_t packsPerLine = m_width / PIXELS_PER_PACK;

 for (uint32_t line = 0; line < m_height; line++)
 {
 // Lines start at 128 byte alignment
 const uint32_t* src = (const uint32_t*)(inBuffer + (ptrdiff_t)(line * stride));

 for (uint32_t pack = 0; pack < packsPerLine; pack++)
 {
 uint32_t val;
 uint16_t u, y1, y2, v;

 if (pack % 2 == 0)
 {
 V210_READ_PACK_BLOCK(u, y1, v);
 P010_WRITE_VALUE(dstUV, u);
 P010_WRITE_VALUE(dstY, y1);
 P010_WRITE_VALUE(dstUV, v);

 V210_READ_PACK_BLOCK(y1, u, y2);
 P010_WRITE_VALUE(dstY, y1);
 P010_WRITE_VALUE(dstUV, u);
 P010_WRITE_VALUE(dstY, y2);

 V210_READ_PACK_BLOCK(v, y1, u);
 P010_WRITE_VALUE(dstUV, v);
 P010_WRITE_VALUE(dstY, y1);
 P010_WRITE_VALUE(dstUV, u);

 V210_READ_PACK_BLOCK(y1, v, y2);
 P010_WRITE_VALUE(dstY, y1);
 P010_WRITE_VALUE(dstUV, v);
 P010_WRITE_VALUE(dstY, y2);
 }
 else
 {
 V210_READ_PACK_BLOCK(u, y1, v);
 P010_WRITE_VALUE(dstY, y1);

 V210_READ_PACK_BLOCK(y1, u, y2);
 P010_WRITE_VALUE(dstY, y1);
 P010_WRITE_VALUE(dstY, y2);

 V210_READ_PACK_BLOCK(v, y1, u);
 P010_WRITE_VALUE(dstY, y1);

 V210_READ_PACK_BLOCK(y1, v, y2);
 P010_WRITE_VALUE(dstY, y1);
 P010_WRITE_VALUE(dstY, y2);
 }
 }
 }

#ifdef _DEBUG

 // Fully written Y space
 assert(dstY == dstUVStart);

 // Fully written UV space
 const BYTE* expectedVurrentUVPtr = outBuffer + (ptrdiff_t)GetOutFrameSize();
 assert(expectedVurrentUVPtr == (BYTE *)dstUV);

#endif
}



This leads to the Y being correct and the amount of lines for U and V as well, but somehow U and V are not overlaid properly. There are two versions of it seemingly mirrored through the center vertical. Something similar but less visible for zeroing out V. So both of these are getting rendered at half the width ? Any tips appreciated :)


Fix :
Found the bug, I'm flipping VU not per pack but per block


if (pack % 2 == 0)



Should be


if (line % 2 == 0)



-
How to create a command – Introducing the Piwik Platform
2 octobre 2014, par Thomas Steur — DevelopmentThis is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to publish your plugin or theme on the Piwik Marketplace). This time you’ll learn how to create a new command. For this tutorial you will need to have basic knowledge of PHP.
What is a command ?
A command can execute any task on the command line. Piwik provides currently about 50 commands via the Piwik Console. These commands let you start the archiver, change the number of available custom variables, enable the developer mode, clear caches, run tests and more. You could write your own command to sync users or websites with another system for instance.
Getting started
In this series of posts, we assume that you have already set up your development environment. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik.
To summarize the things you have to do to get setup :
- Install Piwik (for instance via git).
- Activate the developer mode :
./console development:enable --full
. - Generate a plugin :
./console generate:plugin --name="MyCommandPlugin"
. There should now be a folderplugins/MyCommandPlugin
. - And activate the created plugin under Settings => Plugins.
Let’s start creating a command
We start by using the Piwik Console to create a new command. As you can see there is even a command that lets you easily create a new command :
./console generate:command
The command will ask you to enter the name of the plugin the created command should belong to. I will simply use the above chosen plugin name “MyCommandPlugin”. It will ask you for a command name as well. I will use “SyncUsers” in this example. There should now be a file
plugins/MyCommandPlugin/Commands/Syncusers.php
which contains already an example to get you started easily :- class Syncusers extends ConsoleCommand
- {
- protected function configure()
- {
- $this->setName('mycommandplugin:syncusers');
- $this->setDescription('MyCommandPlugin');
- $this->addOption('name', null, InputOption::VALUE_REQUIRED, 'Your name:');
- }
- /**
- * Execute command like: ./console mycommandplugin:syncusers --name="The Piwik Team"
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $name = $input->getOption('name');
- $output->writeln($message);
- }
- }
Any command that is placed in the “Commands” folder of your plugin will be available on the command line automatically. Therefore, the newly created command can now be executed via
./console mycommandplugin:syncusers --name="The Piwik Team"
.The code template explained
- protected function configure()
- {
- $this->setName('mycommandplugin:checkdatabase');
- $this->setDescription('MyCommandPlugin');
- $this->addOption('name', null, InputOption::VALUE_REQUIRED, 'Your name:');
- }
As the name says the method
configure
lets you configure your command. You can define the name and description of your command as well as all the options and arguments you expect when executing it.- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $name = $input->getOption('name');
- $output->writeln($message);
- }
The actual task is defined in the
execute
method. There you can access any option or argument that was defined on the command line via$input
and write anything to the console via$output
argument.In case anything went wrong during the execution you should throw an exception to make sure the user will get a useful error message. Throwing an exception when an error occurs will make sure the command does exit with a status code different than 0 which can sometimes be important.
Advanced features
The Piwik Console is based on the powerful Symfony Console component. For instance you can ask a user for any interactive input, you can use different output color schemes and much more. If you are interested in learning more all those features have a look at the Symfony console website.
How to test a command
After you have created a command you are surely wondering how to test it. Ideally, the actual command is quite short as it acts like a controller. It should only receive the input values, execute the task by calling a method of another class and output any useful information. This allows you to easily create a unit or integration test for the classes behind the command. We will cover this topic in one of our future blog posts. Just one hint : You can use another command
./console generate:test
to create a test. If you want to know how to test a command have a look at the Testing Commands documentation.Publishing your Plugin on the Marketplace
In case you want to share your commands with other Piwik users you can do this by pushing your plugin to a public GitHub repository and creating a tag. Easy as that. Read more about how to distribute a plugin and best practices when publishing a plugin.
Isn’t it easy to create a command ? We never even created a file ! If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.
-
How to create a command – Introducing the Piwik Platform
2 octobre 2014, par Thomas Steur — DevelopmentThis is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to publish your plugin or theme on the Piwik Marketplace). This time you’ll learn how to create a new command. For this tutorial you will need to have basic knowledge of PHP.
What is a command ?
A command can execute any task on the command line. Piwik provides currently about 50 commands via the Piwik Console. These commands let you start the archiver, change the number of available custom variables, enable the developer mode, clear caches, run tests and more. You could write your own command to sync users or websites with another system for instance.
Getting started
In this series of posts, we assume that you have already set up your development environment. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik.
To summarize the things you have to do to get setup :
- Install Piwik (for instance via git).
- Activate the developer mode :
./console development:enable --full
. - Generate a plugin :
./console generate:plugin --name="MyCommandPlugin"
. There should now be a folderplugins/MyCommandPlugin
. - And activate the created plugin under Settings => Plugins.
Let’s start creating a command
We start by using the Piwik Console to create a new command. As you can see there is even a command that lets you easily create a new command :
./console generate:command
The command will ask you to enter the name of the plugin the created command should belong to. I will simply use the above chosen plugin name “MyCommandPlugin”. It will ask you for a command name as well. I will use “SyncUsers” in this example. There should now be a file
plugins/MyCommandPlugin/Commands/Syncusers.php
which contains already an example to get you started easily :- class Syncusers extends ConsoleCommand
- {
- protected function configure()
- {
- $this->setName('mycommandplugin:syncusers');
- $this->setDescription('MyCommandPlugin');
- $this->addOption('name', null, InputOption::VALUE_REQUIRED, 'Your name:');
- }
- /**
- * Execute command like: ./console mycommandplugin:syncusers --name="The Piwik Team"
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $name = $input->getOption('name');
- $output->writeln($message);
- }
- }
Any command that is placed in the “Commands” folder of your plugin will be available on the command line automatically. Therefore, the newly created command can now be executed via
./console mycommandplugin:syncusers --name="The Piwik Team"
.The code template explained
- protected function configure()
- {
- $this->setName('mycommandplugin:checkdatabase');
- $this->setDescription('MyCommandPlugin');
- $this->addOption('name', null, InputOption::VALUE_REQUIRED, 'Your name:');
- }
As the name says the method
configure
lets you configure your command. You can define the name and description of your command as well as all the options and arguments you expect when executing it.- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $name = $input->getOption('name');
- $output->writeln($message);
- }
The actual task is defined in the
execute
method. There you can access any option or argument that was defined on the command line via$input
and write anything to the console via$output
argument.In case anything went wrong during the execution you should throw an exception to make sure the user will get a useful error message. Throwing an exception when an error occurs will make sure the command does exit with a status code different than 0 which can sometimes be important.
Advanced features
The Piwik Console is based on the powerful Symfony Console component. For instance you can ask a user for any interactive input, you can use different output color schemes and much more. If you are interested in learning more all those features have a look at the Symfony console website.
How to test a command
After you have created a command you are surely wondering how to test it. Ideally, the actual command is quite short as it acts like a controller. It should only receive the input values, execute the task by calling a method of another class and output any useful information. This allows you to easily create a unit or integration test for the classes behind the command. We will cover this topic in one of our future blog posts. Just one hint : You can use another command
./console generate:test
to create a test. If you want to know how to test a command have a look at the Testing Commands documentation.Publishing your Plugin on the Marketplace
In case you want to share your commands with other Piwik users you can do this by pushing your plugin to a public GitHub repository and creating a tag. Easy as that. Read more about how to distribute a plugin and best practices when publishing a plugin.
Isn’t it easy to create a command ? We never even created a file ! If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.